hookehuyr

优化处理建筑经纬度不在导航列表里的情况

......@@ -12,6 +12,8 @@ const testInfo = [
[120.587736, 31.314093],
[120.5875, 31.31407],
[120.587103, 31.314234],
[120.587046,31.314125],
[120.586958,31.314132],
[120.586912, 31.314195],
[120.586812, 31.314049],
],
......@@ -29,8 +31,11 @@ const testInfo = [
[120.587811, 31.313508],
[120.587736, 31.314093],
[120.5875, 31.31407],
[120.587458,31.314335],
[120.587707,31.314354],
[120.58769, 31.314535],
[120.587352, 31.314496],
[120.587352,31.31482],
[120.587176, 31.314839],
[120.587113, 31.314473],
[120.586966, 31.314526],
......@@ -52,9 +57,15 @@ const testInfo = [
[120.587811, 31.313508],
[120.587736, 31.314093],
[120.587985, 31.31411],
[120.587958,31.314381],
[120.587698,31.314349],
[120.58769, 31.314535],
[120.587882,31.314598],
[120.58798, 31.314679],
[120.58791, 31.314799],
[120.587621,31.31513],
[120.58758,31.315273],
[120.5874,31.315266],
[120.587295, 31.315548],
[120.587574, 31.315582],
[120.587853, 31.315603],
......@@ -65,5 +76,5 @@ const testInfo = [
// 照壁[120.587882,31.312884]-双桥[120.588164,31.31305]-牌坊[120.587823,31.313276]-山门[120.587811,31.313508]-鼓楼[120.5875,31.31407]-公共厕所[120.587103,31.314234]-包子铺[120.586912,31.314195]-开水房[120.586812,31.314049];
// 照壁[120.587882,31.312884]-双桥[120.588164,31.31305]-牌坊[120.587823,31.313276]-山门[120.587811,31.313508]-鼓楼[120.5875,31.31407]-天王殿[120.58769,31.314535]-素食馆[120.587352,31.314496]-罗汉堂[120.587176,31.314839]-集云轩[120.587113,31.314473]-般若堂[120.586966,31.314526]-茶室[120.58681,31.314981]-湖心亭[120.58653,31.315118]-神鼋[120.586157,31.315011];
// 照壁[120.587882,31.312884]-双桥[120.588164,31.31305]-牌坊[120.587823,31.313276]-山门[120.587811,31.313508]-钟楼[120.587985,31.31411]-天王殿[120.58769,31.314535]-客堂、行政办公室[120.58798,31.314679]-观音殿[120.58791,31.314799]-大雄宝殿[,]-老念佛堂[120.587295,31.315548]-挂单寮[120.587574,31.315582]-地藏殿[120.587853,31.315603];
// 照壁[120.587882,31.312884]-双桥[120.588164,31.31305]-牌坊[120.587823,31.313276]-山门[120.587811,31.313508]-钟楼[120.587985,31.31411]-天王殿[120.58769,31.314535]-客堂、行政办公室[120.58798,31.314679]-观音殿[120.58791,31.314799]-大雄宝殿[120.587621,31.31513]-老念佛堂[120.587295,31.315548]-挂单寮[120.587574,31.315582]-地藏殿[120.587853,31.315603];
export default testInfo;
......
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-07-19 16:32:10
* @LastEditTime: 2023-07-19 17:05:37
* @FilePath: /map-demo/src/views/index.vue
* @Description: 地图主体页面
-->
......@@ -658,10 +658,14 @@ export default {
}
})
});
const lngLat = [120.587234, 31.314147]; // 左边
let lngLat = [120.587234, 31.314147]; // 左边
// const lngLat = [120.588178, 31.314396]; // 右边
// 构建路线结构
const route_obj = array;
// 如果建筑不在导航路径上面需要单独处理, 直接查询建筑离哪个导航路径最近显示出来
const route_obj = array.length ? array: my_router;
if (!array.length) {
lngLat = position; // 当前导航建筑经纬度
}
// 计算距离最近的路径
route_obj.forEach((line) => {
line.distance = AMap.GeometryUtil.distanceToLine(lngLat, line.path);
......
<!--
* @Date: 2023-05-19 14:54:27
* @LastEditors: hookehuyr hookehuyr@gmail.com
* @LastEditTime: 2023-07-19 16:34:32
* @LastEditTime: 2023-07-19 17:06:18
* @FilePath: /map-demo/src/views/inner.vue
* @Description: 地图主体页面
-->
......@@ -728,10 +728,14 @@ export default {
}
})
});
const lngLat = [120.587234, 31.314147]; // 左边
let lngLat = [120.587234, 31.314147]; // 左边
// const lngLat = [120.588178, 31.314396]; // 右边
// 构建路线结构
const route_obj = array;
// 如果建筑不在导航路径上面需要单独处理, 直接查询建筑离哪个导航路径最近显示出来
const route_obj = array.length ? array : my_router;
if (!array.length) {
lngLat = position; // 当前导航建筑经纬度
}
// 计算距离最近的路径
route_obj.forEach((line) => {
line.distance = AMap.GeometryUtil.distanceToLine(lngLat, line.path);
......