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
						});
					}
				);
			},
相关推荐
2501_9159184113 分钟前
iOS 框架全解析,原生框架与跨平台框架对比、开发应用打包与 App Store 上架实战经验
android·ios·小程序·https·uni-app·iphone·webview
街尾杂货店&3 小时前
cssword属性
uni-app
鱼樱前端6 小时前
uni-app快速入门章法(二)
前端·uni-app
三天不学习11 小时前
uniapp集成语音识别与图片识别集成方案【百度智能云】
百度·uni-app·语音识别
卷Java1 天前
饼状图修复总结
java·spring boot·uni-app·echarts
闲蛋小超人笑嘻嘻1 天前
find数组方法详解||Vue3 + uni-app + Wot Design(wd-picker)使用自定义插槽内容写一个下拉选择器
前端·javascript·uni-app
2501_916007471 天前
前端开发工具都有哪些?常用前端开发工具清单与场景化推荐
android·ios·小程序·https·uni-app·iphone·webview
2501_915909061 天前
iOS 应用上架全流程解析,苹果应用发布步骤、ipa 上传工具、TestFlight 测试与 App Store 审核经验
android·macos·ios·小程序·uni-app·cocoa·iphone
茶憶1 天前
uniapp 请求接口封装和使用
vue.js·uni-app
肥喵蒙太奇1 天前
uniapp 使用towxml
uni-app