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
						});
					}
				);
			},
相关推荐
喵喵虫21 小时前
uniapp修改封装组件失败 styleIsolation
uni-app
游戏开发爱好者81 天前
日常开发与测试的 App 测试方法、查看设备状态、实时日志、应用数据
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 天前
app 上架过程,安装包准备、证书与描述文件管理、安装测试、上传
android·ios·小程序·https·uni-app·iphone·webview
2501_915106321 天前
使用 Sniffmaster TCP 抓包和 Wireshark 网络分析
网络协议·tcp/ip·ios·小程序·uni-app·wireshark·iphone
宠友信息1 天前
2025社交+IM及时通讯社区APP仿小红书小程序
java·spring boot·小程序·uni-app·web app
“负拾捌”2 天前
python + uniapp 结合腾讯云实现实时语音识别功能(WebSocket)
python·websocket·微信小程序·uni-app·大模型·腾讯云·语音识别
局外人LZ2 天前
Uniapp脚手架项目搭建,uniapp+vue3+uView pro+vite+pinia+sass
前端·uni-app·sass
2501_915918412 天前
在 iOS 环境下查看 App 详细信息与文件目录
android·ios·小程序·https·uni-app·iphone·webview
前端呆头鹅2 天前
Websocket使用方案详解(uniapp版)
websocket·网络协议·uni-app
浮桥3 天前
uniapp+h5 公众号实现分享海报绘制
uni-app·notepad++