小程序Map上边增加控件之坑

本文讨论了小程序中Map组件的局限性及其与cover-view组件结合使用时的问题。详细介绍了如何调整代码顺序以确保在真机上正确显示覆盖视图组件,为开发者提供了实际的解决方案。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

小程序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>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值