// text/mapTrajectory.js Page({ data: { curPosiInfo: null, //位置信息 // latitude: 0, longitude: 0,//经纬度 markers: null, polyline: [{ points: [ { id: 0, latitude: 31.11325, longitude: 121.38206 }, { id: 1, latitude: 31.11305, longitude: 121.38186 }, { id: 2, latitude: 31.11285, longitude: 121.38206 }, { id: 3, latitude: 31.11265, longitude: 121.38186 }, { id: 4, latitude: 31.11255, longitude: 121.38206 }, { id: 5, latitude: 31.11245, longitude: 121.38186 }, { id: 6, latitude: 31.11225, longitude: 121.38206 }, { id: 7, latitude: 31.11205, longitude: 121.38186 } ], color: '#F11D36', width: 2, dottedLine: false }] }, onLoad: function (options) { var title = options.name; //console.log(options)// if(title!="" || title!=undefined){ wx.setNavigationBarTitle({ title: title + '巡检记录', }); } }, onShow: function () { var that=this; that.getlocation(); that.setUpIcon(); }, getlocation: function () { var that=this; wx.getLocation({ type: 'gcj02', success: function (res) { that.setData({ curPosiInfo:res }) }, fail:function(res){console.log(res)} }); }, setUpIcon:function(){ var that = this; var getlocation = that.data.polyline[0].points;//获取轨迹坐标 var startlocation = getlocation[0];//获取轨迹起点坐标 var endlocation = getlocation[getlocation.length - 1];//获取轨迹终点坐标 var markers = []; for (var i = 0; i