一个地图的小例子分享下
效果图:
这是wxml文件中地图部分的代码
<map id="map" longitude="116.410440" latitude="39.970830" scale="14" controls="{{controls}}" bindtap="openMap" bindcontroltap="controltap" markers="{{markers}}" bindmarkertap="markertap" polyline="{{polyline}}" bindregionchange="regionchange" show-location style="width: 100%; height: 150px;"></map>
这是js代码
data: {
markers: [{
iconPath: '/images/icon-location.png',
id: 0,
latitude: 39.970830,
longitude: 116.410440,
width: 30,
height: 30
}]
},
openMap: function () {
wx.openLocation({
latitude: 39.970830,
longitude: 116.410440,
scale: 14,
name: '商务大厦'
})
},