9***@qq.com
9***@qq.com
  • 发布:2022-11-30 12:07
  • 更新:2022-11-30 17:13
  • 阅读:120

【报Bug】map 在ios16系统上不执行@markertap事件

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 21H2

HBuilderX类型: 正式

HBuilderX版本号: 3.6.4

手机系统: iOS

手机系统版本号: iOS 16

手机厂商: 苹果

手机机型: iphone11

页面类型: nvue

vue版本: vue2

打包方式: 离线

项目创建方式: HBuilderX

示例代码:
                              <map  
                  id="map"  
                  style="flex: 1"   
                  :latitude="latitude"  
                  :longitude="longitude"  
                  :scale="zoom"  
                  show-location  
                  @markertap="onClickMarker">  
                </map>
                                  onClickMarker(e) {  
                   console.log("onClickMarker"+e)  
                                   },  
                                  createMapContext() {  
                                      // 创建地图对象  
                    this.map = uni.createMapContext("map", this);  
                    let _this = this  
                     // 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {})  
                    this.map.initMarkerCluster({ // 初始化点聚合的配置  
                            enableDefaultStyle: false, // 是否使用默认样式  
                            zoomOnClick: true,  
                            gridSize: 60,  
                            complete(res) {  
                                console.log('initMarkerCluster', res)  
                            }  
                    })  
                    this.map.on("markerClusterCreate", (e) => {  
                            console.log("markerClusterCreate", e);  
                    })  
                                       this.getVehiclesPosition()  
                                  },  

                             getVehiclesPosition(i) {  
                 postReq("getVehiclesPosition", {vehicleName: this.vehicleName}).then(res=> {  
                     console.log(res)  
                    if(res.result){  
                        let data = res.data  
                        if(data.length>0){  
                            data.forEach((item,index)=>{  
                                    if(item.lat&&item.lng){  
                                        let lnglat = transformFromWGSToGCJ(item.lat-0, item.lng-0)  
                                        if(item.onlineStatus == 1) {  
                                            this.covers.push({  
                                                id: index+1,  
                                                latitude: lnglat.latitude,  
                                                longitude: lnglat.longitude,  
                                                iconPath: '../../static/img/index/cc.png',  
                                                width: 30,  
                                                height: 26,  
                                                joinCluster: true,  
                                                callout: {  
                                                    content: item.vehicleName,  
                                                    color: "rgba(255,255,255,1)",  
                                                    fontSize: 10,  
                                                    borderRadius: 10,  
                                                    bgColor: "rgba(2,167,240,1)",  
                                                    padding: 5,  
                                                    display: "ALWAYS"  
                                                }  
                                            })  
                                        }else{  
                                            // 'code_'+item.code  
                                            this.covers.push({  
                                                id: index+1,  
                                                latitude: lnglat.latitude,  
                                                longitude: lnglat.longitude,  
                                                iconPath: '../../static/img/index/cc1.png',  
                                                width: 30,  
                                                height: 26,  
                                                joinCluster: true,  
                                                callout: {  
                                                    content: item.vehicleName,  
                                                    color: "rgba(0,0,0,1)",  
                                                    fontSize: 10,  
                                                    borderRadius: 10,  
                                                    bgColor: "rgba(204,204,204,1)",  
                                                    padding: 5,  
                                                    display: "ALWAYS"  
                                                }  
                                            })  
                                        }     
                                    }  

                                })  
                                let markers = JSON.parse(JSON.stringify(this.covers))  
                                this.map.addMarkers({  
                                    markers,  
                                    clear: false, // 是否先清空地图上所有marker  
                                })  
                                                   }  
                    }else{  
                        uni.hideLoading()  
                        uni.showToast({  
                            title: res.msg,  
                            icon: 'none'  
                        })  
                    }  
                 }).catch(err=>{  
                    uni.hideLoading()  
                    uni.showToast({  
                        title: err.msg,  
                        icon: 'none'  
                    })  
                })  
               }

操作步骤:
                        this.map.addMarkers({  
                                    markers,  
                                    clear: false, // 是否先清空地图上所有marker  
                                })

预期结果:
                                 onClickMarker(e) {  
                   console.log("onClickMarker"+e) // 打印出结果  
                                  }

实际结果:
    ```  
                   onClickMarker(e) {  
               console.log("onClickMarker"+e) // 未打印出结果  
                              }

bug描述:

map 在ios16系统上不执行@markertap事件

2022-11-30 12:07 负责人:无 分享
已邀请:
9***@qq.com

9***@qq.com (作者) - hello worid

已找到问题,记录一下:
1、markerId IOS上需是数字

2、ios上 e.detail.markerId取不到, JSON.stringify(e.detail.markerId)能取到

要回复问题请先登录注册