map moveToLocation 无法定位到指定位置?
组件: map
api:moveToLocation
微信版本号:7.0.4
基础库:2.8.0 及 以上
手机:ios 9.3.3
moveToLocation 定位只能定位到当前位置,不能定位到指定的位置
html:
< view class = "page-body" > < view class = "page-section page-section-gap" > < map id = "myMap" style = "width: 100%; height: 300px;" latitude = "{{latitude}}" longitude = "{{longitude}}" markers = "{{markers}}" show-location ></ map > </ view > < view class = "btn-area" > < button bindtap = "moveToLocation" class = "page-body-button" type = "primary" >定位</ button > </ view > </ view > |
js:
Page({ data: { latitude: 23.099994, longitude: 113.324520, markers: [{ id: 1, latitude: 23.099994, longitude: 113.324520, name: 'T.I.T 创意园' }] }, onReady: function (e) { this .mapCtx = wx.createMapContext( 'myMap' ) }, moveToLocation: function () { this .mapCtx.moveToLocation({ latitude: 23.099994, longitude: 113.324520 }) }, }) |
css:
.page-section-gap{ box-sizing: border-box; padding : 0 30 rpx; } .page-body-button { margin-bottom : 30 rpx; } |
3 回复