Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Hooke
/
map-demo
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
hookehuyr
2025-08-08 14:45:57 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8cfcb3566aaa40bad0bf8b25374a376bfec59e26
8cfcb356
1 parent
bd314c4f
fix: 更新AMap安全密钥并添加地图定位范围配置
更新多个视图文件中的AMap安全密钥为最新值 为地图组件添加point_range配置以支持动态设置定位范围
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
50 additions
and
38 deletions
src/views/activity.vue
src/views/bieyuan/map.vue
src/views/by/map.vue
src/views/index.vue
src/views/inner.vue
src/views/mapCutter.vue
src/views/tools.vue
src/views/xys/index.vue
src/views/activity.vue
View file @
8cfcb35
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 202
4-01-08 17:26:45
* @LastEditTime: 202
5-08-08 11:46:19
* @FilePath: /map-demo/src/views/activity.vue
* @Description: 内部地图主体页面
-->
...
...
@@ -235,7 +235,7 @@ const GPS = {
};
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
export default {
components: { InfoWindow, InfoWindowLite, InfoWindowWarn, InfoWindowYard, Floor },
...
...
@@ -329,7 +329,7 @@ export default {
},
async mounted() {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
@@ -341,6 +341,7 @@ export default {
this.mapTiles = data.level; // 获取图层
this.navKey = data.list[0]['id']; // 默认选中 第一个 id
this.navList = data.list.filter(item => item.id === this.navKey)[0]['list']; // 返回默认选中项的实体信息
this.point_range = data.map.map_range ? data.map.point_range : []; // 地图定位范围
// 初始化地图
this.initMap();
// this.setMapBoundary();
...
...
src/views/bieyuan/map.vue
View file @
8cfcb35
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
3-06 10:28:52
* @LastEditTime: 2025-0
8-08 14:44:51
* @FilePath: /map-demo/src/views/bieyuan/map.vue
* @Description: 公众地图主体页面
-->
...
...
@@ -155,7 +155,7 @@ const GPS = {
};
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
export default {
components: { pageInfo, audioBackground1 },
...
...
@@ -269,11 +269,14 @@ export default {
open_current_location: true,
show_toast: false,
toast_text: '',
point_range: [ // 左下角是开始, 顺时针转动, 四个角
[117.044223,26.835105], [117.044227,26.842448], [117.0552,26.842452], [117.055195,26.8351]
],
}
},
async mounted() {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
@@ -288,6 +291,7 @@ export default {
this.data_rotation = data.map.rotation; // 地图旋转角度
this.data_zooms = data.map.zooms.map(item => Number(item)); // 地图默认缩放范围
this.data_paths = data.map.path ? data.map.path : {}; // 地图默认导航路径
this.point_range = data.map.map_range ? data.map.point_range : []; // 地图定位范围
if (data.map.path) {
for (const key in data.map.path) {
const element = data.map.path[key];
...
...
@@ -548,9 +552,7 @@ export default {
// }, 1000);
},
isPointInRing() { // 是否在景区范围
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], [
[117.044223,26.835105], [117.044227,26.842448], [117.0552,26.842452], [117.055195,26.8351]
]);
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], this.point_range);
return isPointInRing
},
setLocation() { // 开启定位服务
...
...
src/views/by/map.vue
View file @
8cfcb35
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
3-22 21:23:42
* @LastEditTime: 2025-0
8-07 16:13:40
* @FilePath: /map-demo/src/views/by/map.vue
* @Description: 公众地图主体页面
-->
...
...
@@ -165,7 +165,7 @@ const GPS = {
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
export default {
...
...
@@ -282,12 +282,15 @@ export default {
toast_text: '',
data_logo: '',
data_layers: [],
point_range: [
[117.044223,26.835105], [117.044227,26.842448], [117.0552,26.842452], [117.055195,26.8351]
],
walking: '',
}
},
async mounted() {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
@@ -303,6 +306,7 @@ export default {
this.data_zooms = data.map.zooms.map(item => Number(item)); // 地图默认缩放范围
this.data_paths = data.map.path ? data.map.path : {}; // 地图默认导航路径
this.data_logo = data.map.map_logo ? data.map.map_logo : ''; // 地图logo
this.point_range = data.map.map_range ? data.map.point_range : []; // 地图定位范围
if (data.map.map_layers) { // 地图默认图层
if (data.map.map_layers === 'satellite') { // 卫星和路网
this.data_layers = [new AMap.TileLayer.Satellite(), new AMap.TileLayer.RoadNet()]
...
...
@@ -608,9 +612,7 @@ export default {
// }, 1000);
},
isPointInRing() { // 是否在景区范围
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], [
[117.044223,26.835105], [117.044227,26.842448], [117.0552,26.842452], [117.055195,26.8351]
]);
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], this.point_range);
return isPointInRing
},
setLocation() { // 开启定位服务
...
...
src/views/index.vue
View file @
8cfcb35
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
3-06 15:46:30
* @LastEditTime: 2025-0
8-07 16:14:55
* @FilePath: /map-demo/src/views/index.vue
* @Description: 公众地图主体页面
-->
...
...
@@ -183,7 +183,7 @@ const GPS = {
};
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
export default {
components: { InfoWindow, InfoWindowLite, InfoWindowWarn, audioBackground, InfoPopup, InfoPopupLite, InfoPopupWarn },
...
...
@@ -265,11 +265,14 @@ export default {
showInfoPopup: false,
showInfoLitePopup: false,
showInfoWarnPopup: false,
point_range: [
[120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005]
], // 接口获取-地图范围
}
},
async mounted() {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
@@ -286,6 +289,7 @@ export default {
this.data_rotation = data.map.rotation; // 地图旋转角度
this.data_zooms = data.map.zooms.map(item => Number(item)); // 地图默认缩放范围
this.data_paths = data.map.path ? data.map.path : {}; // 地图默认导航路径
this.point_range = data.map.map_range ? data.map.point_range : []; // 地图定位范围
if (data.map.path) {
for (const key in data.map.path) {
const element = data.map.path[key];
...
...
@@ -564,9 +568,7 @@ export default {
// });
// },
isPointInRing() { // 是否在景区范围
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], [
[120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005]
]);
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], this.point_range);
return isPointInRing
},
setLocation() { // 开启定位服务
...
...
src/views/inner.vue
View file @
8cfcb35
...
...
@@ -202,7 +202,7 @@ const GPS = {
};
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
export default {
components: { InfoWindow, InfoWindowLite, InfoWindowWarn, InfoWindowYard, Floor },
...
...
@@ -286,7 +286,7 @@ export default {
},
async mounted() {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
@@ -298,6 +298,7 @@ export default {
this.mapTiles = data.level; // 获取图层
this.navKey = data.list[0]['id']; // 默认选中 第一个 id
this.navList = data.list.filter(item => item.id === this.navKey)[0]['list']; // 返回默认选中项的实体信息
this.point_range = data.map.map_range ? data.map.point_range : []; // 地图定位范围
// 初始化地图
this.initMap();
// this.setMapBoundary();
...
...
src/views/mapCutter.vue
View file @
8cfcb35
...
...
@@ -210,12 +210,12 @@ const handleKeydown = (e) => { // 键盘控制
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
onMounted(async () => {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
src/views/tools.vue
View file @
8cfcb35
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
3-06 15:51:20
* @LastEditTime: 2025-0
8-07 16:14:37
* @FilePath: /map-demo/src/views/tools.vue
* @Description: 公众地图主体页面
-->
...
...
@@ -185,7 +185,7 @@ const GPS = {
};
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
export default {
components: { InfoWindow, InfoWindowLite, InfoWindowWarn, audioBackground },
...
...
@@ -265,12 +265,15 @@ export default {
data_zooms: '', // 接口获取-地图默认缩放范围
data_rotation: 0, // 接口获取-地图旋转角度
log_lnglat: '', // 获取当前地址经纬度
temp_rotation: 0
temp_rotation: 0,
point_range: [
[120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005]
], // 接口获取-地图范围
}
},
async mounted() {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
@@ -290,6 +293,7 @@ export default {
this.data_zoom = data.map.zoom; // 地图默认缩放
this.data_rotation = data.map.rotation; // 地图旋转角度
this.data_zooms = data.map.zooms.map(item => Number(item)); // 地图默认缩放范围
this.point_range = data.map.map_range ? data.map.point_range : []; // 地图定位范围
// 初始化地图
this.initMap();
// this.setMapBoundary();
...
...
@@ -521,9 +525,7 @@ export default {
// });
// },
isPointInRing() { // 是否在景区范围
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], [
[120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005]
]);
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], this.point_range);
return isPointInRing
},
setLocation() { // 开启定位服务
...
...
src/views/xys/index.vue
View file @
8cfcb35
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2025-0
3-06 15:52:47
* @LastEditTime: 2025-0
8-07 16:13:08
* @FilePath: /map-demo/src/views/xys/index.vue
* @Description: 公众地图主体页面
-->
...
...
@@ -183,7 +183,7 @@ const GPS = {
};
// 关键安全配置
window._AMapSecurityConfig = {
securityJsCode: '
8602057c4c8dae5bed9a240c0582c46f
', // 替换为你的密钥
securityJsCode: '
ac1a3a5858d74b7d6c50b6858100aa12
', // 替换为你的密钥
}
export default {
components: { InfoWindow, InfoWindowLite, InfoWindowWarn, audioBackground, InfoPopup, InfoPopupLite, InfoPopupWarn },
...
...
@@ -266,11 +266,14 @@ export default {
showInfoLitePopup: false,
showInfoWarnPopup: false,
data_layers: [],
point_range: [
[120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005]
]
}
},
async mounted() {
const AMap = await AMapLoader.load({
key: '
381c6763e1fefd810fbab697f470149c
', // 控制台获取
key: '
17b8fc386104b89db88b60b049a6dbce
', // 控制台获取
version: '2.0', // 指定API版本
plugins: ['AMap.ElasticMarker','AMap.ImageLayer','AMap.ToolBar','AMap.IndoorMap','AMap.Walking','AMap.Geolocation'] // 必须加载步行导航插件
})
...
...
@@ -287,6 +290,7 @@ export default {
this.data_rotation = data.map.rotation; // 地图旋转角度
this.data_zooms = data.map.zooms.map(item => Number(item)); // 地图默认缩放范围
this.data_paths = data.map.path ? data.map.path : {}; // 地图默认导航路径
this.point_range = data.map.map_range ? data.map.point_range : []; // 地图定位范围
if (data.map.map_layers) { // 地图默认图层
if (data.map.map_layers === 'satellite') { // 卫星和路网
this.data_layers = [new AMap.TileLayer.Satellite(), new AMap.TileLayer.RoadNet()]
...
...
@@ -570,9 +574,7 @@ export default {
// });
// },
isPointInRing() { // 是否在景区范围
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], [
[120.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005]
]);
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], this.point_range);
return isPointInRing
},
setLocation() { // 开启定位服务
...
...
Please
register
or
login
to post a comment