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

问题描述

小程序首页使用了地图,之前用的是腾讯地图。但是那个key已经失效了。如果是H5运行的话提示鉴权失败,请传入正确的key

解决办法

在manifest.json配置中的地图配置改为高德地图,并且填写高德地图授权的key即可。如果有腾讯地图已经授权的key改为正确的腾讯地图授权key也是可以的。

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


首页地图部分关键代码

csharp 复制代码
<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>
csharp 复制代码
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
						});
					}
				);
			},
相关推荐
weixin_6383031114 小时前
uniapp组合式和选项式
javascript·vue.js·uni-app
木子啊17 小时前
UniApp Base64上传终极解决方案
uni-app·base64·base64转图片·base64上传
2501_9159184117 小时前
Wireshark、Fiddler、Charles抓包工具详细使用指南
android·ios·小程序·https·uni-app·iphone·webview
阿宇爱吃鱼17 小时前
uniapp input输入框,限制金额输入格式
前端·javascript·uni-app
一只程序熊18 小时前
uniapp x 新手入门指南
uni-app
攻城狮7号1 天前
不懂代码也能造?TRAE+GLM-4.6 手把手教你搭心理咨询智能客服小程序
python·小程序·uni-app·vue·trae·glm我的编程搭子·glm-4.6
QQ588501981 天前
Python_uniapp-心理健康测评服务微信小程序的设计与实现
python·微信小程序·uni-app
三天两行代码1 天前
uniapp 微信小程序实现ai问答功能流式输出makdown解析实现打字机效果(附源码)
微信小程序·小程序·uni-app
三天不学习1 天前
从开发到上架:手把手教你将uni-app微信小程序打包发布(全网最全指南)
微信小程序·uni-app·notepad++
木子啊1 天前
UniApp原生Office预览组件上线
uni-app·在线预览·预览文件·office预览文件