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
2024-08-19 17:37:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
134a102164b72f2163a184d2f5a475d790f8f922
134a1021
1 parent
52f3c5fa
测试获取第一个路径
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
8 deletions
src/views/index.vue
src/views/index.vue
View file @
134a102
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-0
7-12 14:59:31
* @LastEditTime: 2024-0
8-19 17:33:28
* @FilePath: /map-demo/src/views/index.vue
* @Description: 公众地图主体页面
-->
...
...
@@ -48,14 +48,14 @@
<van-icon name="https://cdn.ipadbiz.cn/xys/map/%E5%AE%9A%E4%BD%8Dloc@2x.png" size="1.5rem"
style="vertical-align: middle;" />
</div> -->
<
!-- <
div v-if="open_safe_route" class="item" @click="handleSafeRoute(true)">
<div v-if="open_safe_route" class="item" @click="handleSafeRoute(true)">
<van-icon name="https://cdn.ipadbiz.cn/xys/map/%E7%BA%BF%E8%B7%AF01.png" size="1.5rem"
style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);" />
</div>
<div v-else class="item" @click="handleSafeRoute(false)">
<van-icon name="https://cdn.ipadbiz.cn/xys/map/%E7%BA%BF%E8%B7%AF02.png" size="1.5rem"
style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);" />
</div>
-->
</div>
</div>
</div>
...
...
@@ -244,6 +244,7 @@ export default {
data_zoom: '', // 接口获取-地图默认缩放
data_zooms: '', // 接口获取-地图默认缩放范围
data_rotation: 0, // 接口获取-地图旋转角度
data_paths: {}, // 接口获取-地图导航路径
}
},
async mounted() {
...
...
@@ -259,6 +260,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.data_paths = data.map.path; // 地图默认导航路径
// 初始化地图
this.initMap();
// this.setMapBoundary();
...
...
@@ -595,12 +597,17 @@ export default {
}
},
addSafeRoute() { // 新增路径
// 获取对象的第一个键和值
let firstKey = Object.keys(this.data_paths)[0];
let firstValue = this.data_paths[firstKey];
// 行动路线
var path = [
[120.587645, 31.314833],
[120.587709, 31.314338],
[120.588211, 31.314377],
];
// var path = [
// [120.587645, 31.314833],
// [120.587709, 31.314338],
// [120.588211, 31.314377],
// ];
// console.warn(firstValue);
var path = firstValue;
// 生成折线地图路径
this.current_safe_route = new AMap.Polyline({
path,
...
...
Please
register
or
login
to post a comment