ARTICLE DETAIL

资讯详情

深耕网站建设、视觉设计与SEO优化的一线实战洞察。

uniapp移动端地图提示鉴权失败请传入正确的key问题处理

uniapp移动端地图提示鉴权失败请传入正确的key问题处理

问题描述
小程序首页使用了地图,之前用的是腾讯地图。但是那个key已经失效了。如果是H5运行的话提示鉴权失败,请传入正确的key
在这里插入图片描述
解决办法
在manifest.json配置中的地图配置改为高德地图,并且填写高德地图授权的key即可。如果有腾讯地图已经授权的key改为正确的腾讯地图授权key也是可以的。

"sdkConfigs" : {"maps" : {// "qqmap" : {//     "key" : "VEHBZ-JYJKU-MHHVB-BYEKM-3XMRH-V3BJA"// }"amap": {"key": "高德地图授权的key"}}}

在这里插入图片描述
首页地图部分关键代码

<map id="myMap" style="width: 100%; height: 100%" :latitude="latitude" :longitude="longitude":scale="scale" :markers="markers" :covers="covers" :enableSatellite="enable3D" show-location@markertap="markerClick"></map>
getCenterLocation: function() {this.mapCtx = uni.createMapContext('myMap');let that = this;if (that.showType == 0) {that.mapCtx.getCenterLocation({success: function(res) {that.setData({currentLat: res.latitude,curretnLng: res.longitude});that.getMapLngLat(that.filterCode);that.getMapOrgInfo();},error: function(data) {}});} else {uni.getLocation({type: 'gcj02',success(res) {that.setData({currentLat: res.latitude,curretnLng: res.longitude});that.getMapLngLat(that.filterCode);that.pageOrgListReset();}});}},getMapLngLat: function(areaCode) {let that = this;ygPost.postGetSession('/xx/GetMapLngLat', {areaCode},function(d) {if (areaCode == '100000') {d.data.data.lng = 102.125934;d.data.data.lat = 29.639827;}that.setData({longitude: d.data.data.lng,latitude: d.data.data.lat,scale: 12});});},
返回列表