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
						});
					}
				);
			},
相关推荐
AI多Agent协作实战派15 小时前
AI多Agent协作系统实战(二十二):从6列到12列——任务监控报告的进化之路
java·人工智能·uni-app·bug
小杨小杨、努力变强!18 小时前
VS Code运行HBuilder X中的uni-app项目
vscode·uni-app·uni-app run
码兄科技1 天前
实战:基于Spring Boot + UniApp的地理信息小程序开发
spring boot·后端·uni-app
2501_916007472 天前
iOS和macOS应用程序性能分析和优化工具使用综合指南
android·macos·ios·小程序·uni-app·iphone·webview
2501_916007473 天前
深入理解HTTPS对称与非对称加密机制及Charles抓包实践
网络协议·http·ios·小程序·https·uni-app·iphone
小徐_23333 天前
AI 写 wot-ui 总在猜 API?我们把 Skills、MCP 和 CLI 都配好了
前端·uni-app·ai编程
Liu.7743 天前
uni-app 组件 uni-easyinput 常见 Bug 及解决方案
uni-app·bug
小徐_23333 天前
uni-app 项目别再从零搭了!3 个 Wot UI 起手模板怎么选?
前端·uni-app
蜡台3 天前
uniapp pdf文件预览组件
pdf·uni-app·合同·pdfh5
凡泰AI3 天前
如何借助MCP打通企业APP内部服务:从统一调用到小程序承接
小程序·uni-app·app·mpaas·mcp·小程序容器