123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165 |
- (function () {
- var page = {
- init: function ($page) {
- //页面初始化
- $page.find('#date2').lrdate({
- type: 'date'
- });
- $page.find('.lr-btn-primary').on('tap', function(){
- var date = $('#date2')[0].innerText;
- console.log(date);
- $('.widthset').hide();
- $('.outcase').show();
- });
- //地图初始化
- learun.routeMap = new AMap.Map('route-map', {
- center: [117.000923, 36.675807],
- zoom: 15
- });
- //test
- learun.initPage = function(PathSimplifier) {
- //创建组件实例
- learun.pathSimplifierIns = new PathSimplifier({
- zIndex: 100,
- map: learun.routeMap, //所属的地图实例
- getPath: function(pathData, pathIndex) {
- //返回轨迹数据中的节点坐标信息,[AMap.LngLat, AMap.LngLat...] 或者 [[lng|number,lat|number],...]
- return pathData.path;
- },
- renderOptions: {
- //轨迹线的样式
- pathLineStyle: {
- strokeStyle: 'red',
- lineWidth: 6,
- dirArrowStyle: true
- }
- }
- });
-
- //这里构建两条简单的轨迹,仅作示例
- learun.pathSimplifierIns.setData([{
- name: '轨迹0',
- path: [
- [100.340417, 27.376994],
- [100.239417, 27.3764],
- [100.238417, 27.386994],
- [100.137417, 27.379994],
- [100.436417, 27.396994],
- [100.535417, 27.376694],
- [100.134417, 27.374994],
- [100.232417, 27.372994],
- [100.331417, 27.376994],
- ]
- }]);
-
- //创建一个巡航器
- var navg0 = learun.pathSimplifierIns.createPathNavigator(0, //关联第1条轨迹
- {
- loop: true, //循环播放
- speed: 10000
- });
-
- //播放速度控制
- $page.find('.speed-set').on('tap', function () {
- var speedSign = $page.find('#speed-icon');
- if(speedSign.hasClass('icon-beisu1')){
- speedSign.removeClass('icon-beisu1');
- speedSign.addClass('icon-beisu2');
- $page.find('.speed-level').html('中速');
- navg0.setSpeed(2*10000);
- }else if(speedSign.hasClass('icon-beisu2')){
- speedSign.removeClass('icon-beisu2');
- speedSign.addClass('icon-beisu4');
- $page.find('.speed-level').html('快速');
- navg0.setSpeed(4*10000);
- }else if(speedSign.hasClass('icon-beisu4')){
- speedSign.removeClass('icon-beisu4');
- speedSign.addClass('icon-beisu1');
- $page.find('.speed-level').html('慢速');
- navg0.setSpeed(10000);
- }
- });
- // 播放暂停切换
- $page.find('.icon-bofang').on('tap', function () {
- var playSign = $page.find('#play-pause');
- if(playSign.hasClass('icon-bofang')){
- playSign.removeClass('icon-bofang');
- playSign.addClass('icon-zanting');
- if(navg0.getNaviStatus() == 'stop'){
- navg0.start();
- }else{
- navg0.resume();
- }
- }else{
- playSign.removeClass('icon-zanting');
- playSign.addClass('icon-bofang');
- navg0.pause();
- }
- });
- //节点控制
- $page.find('.icon-last').on('tap', function () {
- if(navg0.getNaviStatus() == 'stop'){
- return;
- }
- if(navg0.getNaviStatus() == 'moving'){
- navg0.pause();
- $('#play-pause').removeClass('icon-bofang');
- $('#play-pause').addClass('icon-zanting');
- }
- //当前节点索引
- var lastNode = navg0.getCursor().idx;
- console.log(lastNode);
- if(lastNode == 0){
- navg0.moveToPoint(0, 0);
- console.log('tt');
- return;
- }
-
-
- console.log(navg0.getCursor());
- navg0.moveToPoint(lastNode-1, 0);
- });
- $page.find('.icon-next').on('tap', function () {
- //下一个节点
- var nextNode = navg0.getCursor().idx + 1;
- if(!lastNode){
- lastNode = 0;
- }
- navg0.pause();
- navg0.moveToPoint(lastNode, 0);
- });
- }
-
- AMapUI.load(['ui/misc/PathSimplifier'], function(PathSimplifier) {
- if (!PathSimplifier.supportCanvas) {
- alert('当前环境不支持 Canvas!');
- return;
- }
-
- //启动页面
- console.log(PathSimplifier);
- learun.initPage(PathSimplifier);
- });
-
- }
- };
- return page;
- })();
|