300字范文,内容丰富有趣,生活中的好帮手!
300字范文 > 微信小程序map组件地图定位当前位置

微信小程序map组件地图定位当前位置

时间:2020-02-21 17:25:40

相关推荐

微信小程序map组件地图定位当前位置

小程序map组件的应用方式:简单版

wxml:

<map id="map" latitude="{{latitude}}" longitude="{{longitude}}" controls="{{controls}}" bindcontroltap="controltap"markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" scale="14" show-location></map>

wxss:

page{ width: 100%; height:100%; }#map{ width: 100%; height:100%; }

js:

data: {markers: [], //地图参数:latitude: "", //纬度 longitude: "", //经度},regionchange(e) {//console.log(e)},markertap(e) {//console.log(e)},controltap(e) {//console.log(e)},//获得地图getMyMap(e) {let that = this;//自行查询经纬度 /maps.htmconst mapLatitude = 23.1194300000,mapLongitude = 113.3212200000;wx.getLocation({type: 'wgs84', success(res){// 当前自己的经纬度 res.latitude,res.longitudethat.setData({latitude: mapLatitude,longitude: mapLongitude,markers: [{id: "0",latitude: mapLatitude,longitude: mapLongitude,iconPath: "/Public/xcx-hitui/image/imgs-jyh/map-ico.png",width: 40,height: 40,callout: {'display': 'ALWAYS', 'fontSize': '30rpx', 'content': '广州珠江新城','padding': '8rpx', 'boxShadow': '0 0 5rpx #333','borderRadius':'4rpx'}}],})}})},/*** 生命周期函数--监听页面加载*/onLoad: function (options) {this.getMyMap()},

有什么错误或优化的地方,可以提出来,大家一起学习研究…

复杂版:微信小程序map组件路线规划,腾讯地图sdk的应用案例

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。