小程序Map做的很基础,功能不完善,由于Map置于最顶层,所以就得用到cover-view来做上层组件,但位置一定要注意,用下方方式写在开发工具上预览正常,但在真机上就失效。
<cover-view style='position:fixed;bottom:20px;left:20px;z-index:999;' bindtap='bindMark'>
<cover-image src="/pages/images/mark.png">
</cover-image>
<cover-view style='color:#fff;font-weight:999;background:#009900;padding:10rpx;border-radius:30rpx;margin-top:5rpx;'>标注位置</cover-view>
</cover-view>
<cover-view style='position:fixed;bottom:20px;right:20px;z-index:999;' bindtap='bindMark'>
<cover-image src="/pages/images/qinzi.png">
</cover-image>
<cover-view style='color:#fff;font-weight:999;background:#990000;padding:10rpx;border-radius:30rpx;margin-top:5rpx;'>确认位置</cover-view>
</cover-view>
<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" markers="{{markers}}" scale="14" show-compass='true' bindcontroltap="controltap" bindmarkertap="markertap" bindregionchange="bindregionchange" bindpoitap="bindpoi" show-location style="width: 100%; height: 100%;"></map>
需要调换一下位置才可以在真机上显示正确,代码如下:
<map id="map" longitude="{{longitude}}" latitude="{{latitude}}" markers="{{markers}}" scale="14" show-compass='true' bindcontroltap="controltap" bindmarkertap="markertap" bindregionchange="bindregionchange" bindpoitap="bindpoi" show-location style="width: 100%; height: 100%;"></map>
<cover-view style='position:fixed;bottom:20px;left:20px;z-index:999;' bindtap='bindMark'>
<cover-image src="/pages/images/mark.png">
</cover-image>
<cover-view style='color:#fff;font-weight:999;background:#009900;padding:10rpx;border-radius:30rpx;margin-top:5rpx;'>标注位置</cover-view>
</cover-view>
<cover-view style='position:fixed;bottom:20px;right:20px;z-index:999;' bindtap='bindMark'>
<cover-image src="/pages/images/qinzi.png">
</cover-image>
<cover-view style='color:#fff;font-weight:999;background:#990000;padding:10rpx;border-radius:30rpx;margin-top:5rpx;'>确认位置</cover-view>
</cover-view>
本文讨论了小程序中Map组件的局限性及其与cover-view组件结合使用时的问题。详细介绍了如何调整代码顺序以确保在真机上正确显示覆盖视图组件,为开发者提供了实际的解决方案。
1336

被折叠的 条评论
为什么被折叠?



