组件:https://mp.weixin.qq.com/debu...
API:https://mp.weixin.qq.com/debu...
效果就像滴滴出行的地图,可以进行选点,让标记(markers)一直居中,用户滑动放手后,获取地图中心点坐标
组件:https://mp.weixin.qq.com/debu...
API:https://mp.weixin.qq.com/debu...
效果就像滴滴出行的地图,可以进行选点,让标记(markers)一直居中,用户滑动放手后,获取地图中心点坐标
查看接口文档:wx.createMapContext(myMap)
wxml:
<map id="myMap"></map>
js:
var mapCtx = wx.createMapContext(myMap)
var latitude,longitude;
mapCtx.getCenterLocation({
success:function(res){
latitude = res.latitude;
longitude = res.longitude;
}
}) //获取当前地图的中心经纬度
mapCtx.includePoints({
padding:[10],
points:[{
latitude:latitude
longitude:longitude
}]
})
mapCtx.translateMarker({
markerId: 0,
autoRotate: true,
duration: 1000,
destination: {
latitude:latitude,
longitude:longitude,
},
animationEnd() {
console.log('animation end')
}
})
13 回答12.8k 阅读
7 回答2k 阅读
3 回答1.1k 阅读✓ 已解决
2 回答1.2k 阅读✓ 已解决
6 回答918 阅读✓ 已解决
6 回答1.1k 阅读
2 回答1.3k 阅读✓ 已解决
标记marker可以用control来做,将这个control定位在地图中间就行;
放手后获取地图中心坐标需要用regionchange,他可以判断当前对地图的操作状态,当e.type为end时用mapContext 获取到地图中心的位置;
相关文档:https://mp.weixin.qq.com/debu...
https://mp.weixin.qq.com/debu...