const APP = getApp(); let mapContext; //地图对象 Page({ /** * 页面的初始数据 */ data: { mapCenter: { //地图聚焦中心 默认北京 latitude: 39.5395312, longitude: 116.7265250, }, markers: [ { id: 1, iconPath: "/imgs/marker.png", latitude: 39.54843965881564, longitude: 116.77418632902149, width: 35, height: 35 }, { id: 2, iconPath: "/imgs/marker.png", latitude: 39.547527631306934, longitude: 116.77166040587744, width: 35, height: 35 }, { id: 3, iconPath: "/imgs/marker.png", latitude: 39.5434256, longitude: 116.7548242, width: 35, height: 35 }, { id: 4, iconPath: "/imgs/marker.png", latitude: 39.5395312, longitude: 116.7265250, width: 35, height: 35 } , { id: 5, iconPath: "/imgs/marker.png", latitude: 39.5368093, longitude: 116.7186292, width: 35, height: 35 }], polyline: [{ points: [ { latitude: 39.54843965881564, longitude: 116.77418632902149 }, { latitude: 39.547527631306934, longitude: 116.77166040587744 }, { latitude: 39.5434256, longitude: 116.7548242 }, { latitude: 39.5395312, longitude: 116.7265250 }, { latitude: 39.5368093, longitude: 116.7186292 }], width: 5, arrowLine: true, color: "#5D88FF" }], }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { // 获取地图对象 mapContext = wx.createMapContext('map'); }, /** * 生命周期函数--监听页面显示 */ onShow: function () { }, })