1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
| const app = getApp() const { getMarkers } = require('@/utils/api') Page({ data: { currLoca: {}, markers: [], }, init() { this.setData({ currLoca: app.globalData.location, }) wx.createMapContext('map').moveToLocation(this.data.currLoca) this.getMapMarkers() }, async getMapMarkers() { wx.showLoading({ title: '加载中', }) let that = this let markarr = [] const userInfo = app.globalData.userInfo let data = { phone: userInfo.phonenumber, userId: userInfo.userId, token: userInfo.token, } const res = await getMarkers(data) res.forEach((it, index) => { let markObj = { id: index, latitude: it.lat, longitude: it.lng, iconPath: '../../images/box.png', width: '72rpx', height: '52rpx', zIndex: index + 1, } markarr.push(markObj) }) this.setData({ markers: markarr, }) wx.hideLoading() }, markertap(e) { console.log('=markertap=', e) }, bindregionchange(e) { console.log('=bindregiοnchange=', e) }, bindtapMap(e) { console.log('=bindtapMap=', e) } onLoad(options) { this.init() }, })
|