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-09-19 15:37:37 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c067b9f8a2cacd00e5f4801106403f3e2acbf5b4
c067b9f8
1 parent
b0331a6f
fix 测试定位问题
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
29 deletions
src/views/bieyuan/map.vue
src/views/bieyuan/map.vue
View file @
c067b9f
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2024-09-19 1
4:12:11
* @LastEditTime: 2024-09-19 1
5:36:09
* @FilePath: /map-demo/src/views/bieyuan/map.vue
* @Description: 公众地图主体页面
-->
...
...
@@ -52,6 +52,10 @@
<div v-if="!show_walk_route" @click="removeSafeRoute('test')" class="walk-nav-text">
关闭步行导航
</div>
<van-dialog v-model:show="dialog_show" title="温馨提示">
<div style="padding: 1rem; text-align: center;">{{ dialog_text }}</div>
</van-dialog>
</div>
</template>
...
...
@@ -357,10 +361,13 @@ export default {
}
});
this.map.add(this.markerSum);
// 获取定位打标记
this.setLocation();
//
},
isPointInRing() { // 是否在景区范围
let isPointInRing = AMap.GeometryUtil.isPointInRing([this.current_lng, this.current_lat], [
[1
20.585111, 31.316084], [120.585111, 31.316084], [120.589488, 31.313197], [120.585422, 31.313005
]
[1
17.044223,26.835105], [117.044227,26.842448], [117.0552,26.842452], [117.055195,26.8351
]
]);
return isPointInRing
},
...
...
@@ -371,31 +378,6 @@ export default {
this.dialog_text = '获取经纬度失败';
}
this.getLocation();
// // this.map.addControl(this.geolocation); // 添加定位图标 自动跳转当前位置
// if (!this.current_lng || !this.current_lat) {
// this.getLocation()
// } else {
// // 判断是否在范围内
// if (!this.isPointInRing()) {
// this.dialog_show = true;
// this.dialog_text = '您不在景区范围内';
// } else {
// // this.current_lng = '120.587643'
// // this.current_lat = '31.314853'
// // 使用纠正偏移后的地址,打一个定位标记
// this.location_marker = new AMap.LabelMarker({
// icon: {
// image: 'https://cdn.ipadbiz.cn/xys/map/%E5%AE%9A.png',
// anchor: 'bottom-center',
// size: [36, 36],
// },
// position: new AMap.LngLat(this.current_lng, this.current_lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
// });
// this.map.add(this.location_marker);
// // 定位到当前位置中心
// this.map.setZoomAndCenter(this.zoom, [this.current_lng, this.current_lat]);
// }
// }
},
getLocation() { // 获取经纬度
// PC端无法获取定位
...
...
@@ -417,9 +399,9 @@ export default {
// 使用纠正偏移后的地址,打一个定位标记
this.location_marker = new AMap.LabelMarker({
icon: {
image: 'https://cdn.ipadbiz.cn/
xys/map/%E5%AE%9A
.png',
image: 'https://cdn.ipadbiz.cn/
bieyuan/map/icon/Group%2034@3x
.png',
anchor: 'bottom-center',
size: [
36, 36
],
size: [
65, 65
],
},
position: new AMap.LngLat(this.current_lng, this.current_lat), // 经纬度对象,也可以是经纬度构成的一维数组[116.39, 39.9]
});
...
...
Please
register
or
login
to post a comment