微信小程序 地圖map實例詳解
成都創(chuàng)新互聯(lián)公司主營桑珠孜網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營網(wǎng)站建設(shè)方案,APP應(yīng)用開發(fā),桑珠孜h5微信小程序開發(fā)搭建,桑珠孜網(wǎng)站營銷推廣歡迎桑珠孜等地區(qū)企業(yè)咨詢
wxml:
class="button" bindtap="getlocation" markers="{{markers}}">定位 longitude="{{longitude}}" latitude="{{latitude}}" markers="{{markers}}" covers="{{covers}}" >
js:
//獲取應(yīng)用實例 var app = getApp() Page({ data: { latitude: 0,//緯度 longitude: 0,//經(jīng)度 speed: 0,//速度 accuracy: 16,//位置精準(zhǔn)度 markers: [], covers: [], }, onLoad: function () { }, getlocation: function () { var markers = [{ latitude: 28.211400, longitude: 112.914250, name: '喜地大廈', desc: '我的位置' }] var covers = [{ latitude: 28.211400, longitude: 112.914250, iconPath: '/image/ic_position.png', rotate: 0 }] this.setData({ longitude: 112.914250, latitude: 28.211400, markers: markers, covers: covers, }) wx.getLocation({ type: 'gcj02', success: function (res) { var latitude = res.latitude var longitude = res.longitude var speed = res.speed var accuracy = res.accuracy console.log("latitude:" + latitude) console.log("longitude:" + longitude) console.log("speed:" + speed) console.log("accuracy:" + accuracy) wx.openLocation({ latitude: latitude, longitude: longitude, scale: 28 }) } }) } })
效果圖:
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!