微信小程序地图组件有哪些?
微信小程序地图组件已经为大家整理出来了。以下是小编对微信小程序地图组件的计算了。大家在开发微信小程序地图的时候,会使用到以下的微信小程序地图组件,以下内容供大家从哪里。
微信小程序地图组件:
wx.createMapContext(mapId)
创建并返回 map 上下文mapContext小程序对象
mapContext
mapContext通过 mapId 跟一个组件绑定,通过它可以操作对应的小程序组件。
mapContext 对象的方法列表:
getCenterLocation 的 OBJECT 参数列表:
translateMarker 的 OBJECT 参数列表:
includePoints 的 OBJECT 参数列表:
getRegion 的 OBJECT 参数列表:
getScale 的 OBJECT 参数列表:
示例微信小程序代码:
// map.js
Page({
onReady: function (e) {
// 使用 wx.createMapContext 获取 map 上下文
this.mapCtx = wx.createMapContext('myMap')
},
getCenterLocation: function () {
this.mapCtx.getCenterLocation({
success: function(res){
console.log(res.longitude)
console.log(res.latitude)
}
})
},
moveToLocation: function () {
this.mapCtx.moveToLocation()
},
translateMarker: function() {
this.mapCtx.translateMarker({
markerId: 0,
autoRotate: true,
duration: 1000,
destination: {
latitude:23.10229,
longitude:113.3345211,
},
animationEnd() {
console.log('animation end')
}
})
},
includePoints: function() {
this.mapCtx.includePoints({
padding: [10],
points: [{
latitude:23.10229,
longitude:113.3345211,
}, {
latitude:23.00229,
longitude:113.3345211,
}]
以上微信小程序地图组件控制的全部内容了。以上全部内容供大家参考。大家在开发微信小程序地图的时候一定会用到上方的内容哦,所以大家可以去把以上内容保存起来。请多关注微小乔。
相关推荐:
微信小程序卫星地图开发实例
微信小程序地图导航,景区地图导航应用微信小程序
微信小程序导航地图开发实例