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
						});
					}
				);
			},
相关推荐
你很易烊千玺17 小时前
即时通讯小程序
小程序·uni-app·直播
风雨兼程^_^18 小时前
ai生成文章,流式传输(uniapp,微信小程序)
ai·微信小程序·uni-app·流式传输
2501_915918411 天前
Web 前端可视化开发工具对比 低代码平台、可视化搭建工具、前端可视化编辑器与在线可视化开发环境的实战分析
前端·低代码·ios·小程序·uni-app·编辑器·iphone
2501_915106321 天前
iOS 使用记录和能耗监控实战,如何查看电池电量消耗、App 使用时长与性能数据(uni-app 开发调试必备指南)
android·ios·小程序·uni-app·cocoa·iphone·webview
iOS阿玮1 天前
苹果卡审情况将逐步缓解,合规的开发者请耐心等待~
uni-app·app·apple
2501_916013741 天前
HTTPS 抓包难点分析,从端口到工具的实战应对
网络协议·http·ios·小程序·https·uni-app·iphone
2501_915918412 天前
uni-app 项目 iOS 上架效率优化 从工具选择到流程改进的实战经验
android·ios·小程序·uni-app·cocoa·iphone·webview
00后程序员张2 天前
如何在不同 iOS 设备上测试和上架 uni-app 应用 实战全流程解析
android·ios·小程序·https·uni-app·iphone·webview
耶啵奶膘2 天前
uni-app头像叠加显示
开发语言·javascript·uni-app
chéng ௹2 天前
uniapp 封装uni.showToast提示
前端·javascript·uni-app