3***@qq.com
3***@qq.com
  • 发布:2022-11-16 11:05
  • 更新:2022-11-16 11:27
  • 阅读:364

【报Bug】地图API中addMakers无效

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10 企业版

HBuilderX类型: 正式

HBuilderX版本号: 3.6.4

手机系统: Android

手机系统版本号: Android 9.0

手机厂商: 模拟器

手机机型: V1938CT

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:
onLoad(options) {  
            this.initMap();  
        },  
initMap(){  
                this.aMapPlugin = new amap.AMapWX({  
                    key: app.globalData.aMap.wxSmailApp  
                });  

                this.mapContext = uni.createMapContext("deviceMap", this);  
                // 仅调用初始化,才会触发 on.("markerClusterCreate", (e) => {})  
                this.mapContext.initMarkerCluster({  
                    enableDefaultStyle: false,  
                    zoomOnClick: true,  
                    gridSize: 60,  
                    complete(res) {  
                        console.log('initMarkerCluster', res)//此输出没有  
                    }  
                });  

                this.mapContext.on("markerClusterCreate", (e) => {  
                    console.log("markerClusterCreate", e);//此输出没有  
                });  

                this.getLocation();  
            },  
getLocation(){  
                let me = this;  
                uni.getLocation({  
                    type: 'wgs84',  
                    success: function (res) {  
                        let initPositon = GSP.GSP.gcj_encrypt(res.latitude, res.longitude);//wgs84转gcj-02  
                        me.queryAMapLocation(initPositon.lon, initPositon.lat);  
                    },  
                    fail: function(res){  
                        console.log(res);  
                    }  
                });  
            },  
queryAMapLocation(lng, lat){  
                const me = this;  
                app.requestApi("/getAMapData", {  
                    lng: lng,  
                    lat: lat  
                }, function(result) {  
                    if (result.data) {  
                        //处理成功  
                        me.markers = [  
                            {  
                                id: 1,  
                                latitude: lat,  
                                longitude: lng,  
                                // width: 50,  
                                // height: 50,  
                                // iconPath: img  
                            }  
                        ];  
                        me.mapContext = uni.createMapContext("deviceMap", me);  
                        me.mapContext.addMarkers({  
                            markers: me.markers,  
                            complete: function(res){  
                                console.log(res);//此输出没有  
                            }  
                        });  
                    } else {  
                        //处理失败  
                        uni.showToast({  
                            title: result.data.info,  
                            icon: "none"  
                        });  
                    }  
                });  
            },

操作步骤:

每次结果都一样,无法出现marker

预期结果:

地图上出现marker

实际结果:

无法使用

bug描述:

使用uniapp中引入map组件,调用addmarkers无效,完成函数不输出任何内容
markers直接加到<map>中是能出现的,但用API就无法添加
在站内搜索到同类型问题,确认HBuilderX为最新正式版

2022-11-16 11:05 负责人:无 分享
已邀请:
3***@qq.com

3***@qq.com (作者)

参考站内文章https://ask.dcloud.net.cn/question/138515
和他的结果是一样的

3***@qq.com

3***@qq.com (作者)

参考站内文章https://ask.dcloud.net.cn/question/89300
用另一种方式实现了效果,没有用到BUG中提到的API

该问题目前已经被锁定, 无法添加新回复