// packageA/pages/historicalTrackDetailMap/historicalTrackDetailMap.js Page({ /** * 页面的初始数据 */ data: { latitude: null, longitude: null, polyline: [], arrLine: [], arrLine1: [ { latitude: "31.22115", longitude: "121.54407" }, { latitude: "31.22114", longitude: "121.54409" }, { latitude: "31.22112", longitude: "121.54410" }, ], remark: "", markers: "", imagesTU: "", points: [], }, onLoad: function (options) { console.log("options///////", options) if (options.url == undefined && options.remark == undefined) { console.log("1") let LineArr = options.dates.split(";") let arr1 = [] LineArr.forEach((item, index) => { arr1.push({ latitude: item.split(",")[0], longitude: item.split(",")[1], }) }) arr1.pop() var that = this that.setData({ latitude: arr1[0].latitude, longitude: arr1[0].longitude, arrLine: arr1, points: arr1, }) that.lineRoad() that.marksDots1() } else { console.log("2") console.log(options.images, 'options.images'); const key = 'detailMapInfo'; let images = wx.getStorageInfo(key) let arr = options.url.split(",") let LineArr = options.dates.split(";") let arr1 = [] LineArr.forEach((item, index) => { let a1 = item.split(",")[0] let a2 = item.split(",")[1] if (a1 != 0 && a2 != 0) { arr1.push({ latitude: a1, longitude: a2 }) } }) // arr1.pop() console.log(arr1) var that = this console.log(arr[0], arr[1]) that.setData({ latitude: arr[0], longitude: arr[1], arrLine: arr1, remark: options.remark, imagesTU: images, points: arr1, }) that.lineRoad() that.marksDots() ////console.log("imagesTU",that.data.imagesTU) ////console.log("路线",that.data.arrLine) ////console.log("路线",that.data.arrLine[0]) ////console.log("路线",that.data.arrLine[that.data.arrLine.length-1]) } }, lineRoad() { var that = this that.setData({ polyline: [ { points: that.data.arrLine, color: "#ff9900", width: 9, arrowLine: true, borderWidth: 1, borderColor: "#555", }, ], }) }, viewMoviePostImg: function (e) { var src = e.currentTarget.dataset.src wx.previewImage({ current: src, // 当前显示图片的http链接 urls: [src], // 需要预览的图片http链接列表 }) }, marksDots() { var that = this console.log("that.data.arrLine", that.data.arrLine) that.setData({ markers: [ { iconPath: "/images/icon/wz.png", id: 0, latitude: that.data.latitude, longitude: that.data.longitude, width: 40, height: 60, }, { iconPath: "/images/icon/wzEnd.png", id: 0, latitude: that.data.arrLine[that.data.arrLine.length - 1].latitude, longitude: that.data.arrLine[that.data.arrLine.length - 1].longitude, width: 33, height: 50, }, { iconPath: "/images/icon/wzStar.png", id: 0, latitude: that.data.arrLine[0].latitude, longitude: that.data.arrLine[0].longitude, width: 26, height: 40, }, ], }) }, marksDots1() { var that = this that.setData({ markers: [ { iconPath: "/images/icon/wzEnd.png", id: 0, latitude: that.data.arrLine[that.data.arrLine.length - 1].latitude, longitude: that.data.arrLine[that.data.arrLine.length - 1].longitude, width: 33, height: 50, }, { iconPath: "/images/icon/wzStar.png", id: 0, latitude: that.data.arrLine[0].latitude, longitude: that.data.arrLine[0].longitude, width: 26, height: 40, }, ], }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () {}, /** * 生命周期函数--监听页面显示 */ onShow: function () {}, /** * 生命周期函数--监听页面隐藏 */ onHide: function () {}, /** * 生命周期函数--监听页面卸载 */ onUnload: function () {}, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () {}, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () {}, /** * 用户点击右上角分享 */ onShareAppMessage: function () {}, })