update
This commit is contained in:
+3
-2
@@ -12,8 +12,9 @@
|
||||
securityJsCode: "1b3b86585c863d22db1e7f7636a9e495",
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript"
|
||||
src="https://webapi.amap.com/maps?v=2.0&key=4bbcb216b889f2d612cbed05ae6979c8&plugin=AMap.Driving"></script>
|
||||
<!-- <script type="text/javascript"-->
|
||||
<!-- src="https://webapi.amap.com/maps?v=2.0&key=4bbcb216b889f2d612cbed05ae6979c8&plugin=AMap.Driving"></script>-->
|
||||
<script type="text/javascript" src="./public/amap.js"></script>
|
||||
</head>
|
||||
<style>
|
||||
html, body, #app {
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -22,24 +22,66 @@ export const tabList = [
|
||||
},
|
||||
{
|
||||
name: '急救路线',
|
||||
},
|
||||
];
|
||||
export const mapIcon1 = new URL('/@/assets/img/mapIcon1.png', import.meta.url).href;
|
||||
export const mapIcon2 = new URL('/@/assets/img/mapIcon2.png', import.meta.url).href;
|
||||
export const mapIcon3 = new URL('/@/assets/img/mapIcon3.png', import.meta.url).href;
|
||||
export const mapIcon4 = new URL('/@/assets/img/mapIcon4.png', import.meta.url).href;
|
||||
export const mapIcon5 = new URL('/@/assets/img/mapIcon5.png', import.meta.url).href;
|
||||
export const mapIcon6 = new URL('/@/assets/img/mapIcon6.png', import.meta.url).href;
|
||||
|
||||
export const legend1 = new URL('/@/assets/img/legend1.png', import.meta.url).href;
|
||||
export const legend2 = new URL('/@/assets/img/legend2.png', import.meta.url).href;
|
||||
export const legend3 = new URL('/@/assets/img/legend3.png', import.meta.url).href;
|
||||
export const legend4 = new URL('/@/assets/img/legend4.png', import.meta.url).href;
|
||||
export const legend5 = new URL('/@/assets/img/legend5.png', import.meta.url).href;
|
||||
export const legend6 = new URL('/@/assets/img/legend6.png', import.meta.url).href;
|
||||
export const mapIcons = [mapIcon1, mapIcon2, mapIcon3, mapIcon4, mapIcon5, mapIcon6];
|
||||
|
||||
export const legendList = [
|
||||
{ img: legend1, text: '油田医院' },
|
||||
{ img: legend2, text: '医疗点' },
|
||||
{ img: legend3, text: '救护车' },
|
||||
{ img: legend4, text: '合作医院' },
|
||||
{ img: legend5, text: '地方医院' },
|
||||
{ img: legend6, text: '直升机' },
|
||||
];
|
||||
|
||||
/**
|
||||
* @description 秒转小时
|
||||
* */
|
||||
export function convertSeconds(seconds) {
|
||||
let hours = Math.floor(seconds / 3600);
|
||||
let minutes = Math.floor((seconds % 3600) / 60);
|
||||
let remainingSeconds = seconds % 60;
|
||||
return {
|
||||
hours: hours,
|
||||
minutes: minutes,
|
||||
seconds: remainingSeconds,
|
||||
};
|
||||
}
|
||||
]
|
||||
export const mapIcon1 = new URL('/@/assets/img/mapIcon1.png', import.meta.url).href
|
||||
export const mapIcon2 = new URL('/@/assets/img/mapIcon2.png', import.meta.url).href
|
||||
export const mapIcon3 = new URL('/@/assets/img/mapIcon3.png', import.meta.url).href
|
||||
export const mapIcon4 = new URL('/@/assets/img/mapIcon4.png', import.meta.url).href
|
||||
export const mapIcon5 = new URL('/@/assets/img/mapIcon5.png', import.meta.url).href
|
||||
export const mapIcon6 = new URL('/@/assets/img/mapIcon6.png', import.meta.url).href
|
||||
|
||||
export const legend1 = new URL('/@/assets/img/legend1.png', import.meta.url).href
|
||||
export const legend2 = new URL('/@/assets/img/legend2.png', import.meta.url).href
|
||||
export const legend3 = new URL('/@/assets/img/legend3.png', import.meta.url).href
|
||||
export const legend4 = new URL('/@/assets/img/legend4.png', import.meta.url).href
|
||||
export const legend5 = new URL('/@/assets/img/legend5.png', import.meta.url).href
|
||||
export const legend6 = new URL('/@/assets/img/legend6.png', import.meta.url).href
|
||||
export const mapIcons = [mapIcon1, mapIcon2, mapIcon3, mapIcon4, mapIcon5, mapIcon6]
|
||||
export function convertMetersToKilometers(meters) {
|
||||
let kilometers = meters / 1000;
|
||||
return Math.round(kilometers * 100) / 100;
|
||||
}
|
||||
|
||||
export const legendList = [{img: legend1, text: '油田医院'}, {img: legend2, text: '医疗点'}, {
|
||||
img: legend3,
|
||||
text: '救护车'
|
||||
}, {img: legend4, text: '合作医院'}, {img: legend5, text: '地方医院'}, {img: legend6, text: '直升机'}]
|
||||
export function getTimeStr(time) {
|
||||
let str = '';
|
||||
const { hours, minutes } = convertSeconds(time);
|
||||
|
||||
if (hours) {
|
||||
str += hours + '小时';
|
||||
}
|
||||
if (minutes) {
|
||||
str += minutes + '分钟';
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
export function getKmStr(distance) {
|
||||
if (!distance) return '';
|
||||
let d = convertMetersToKilometers(distance);
|
||||
return d >= 1 ? d + '公里' : d * 100 + '米';
|
||||
}
|
||||
@@ -61,7 +61,7 @@
|
||||
import { onMounted, ref } from 'vue';
|
||||
import * as echarts from 'echarts';
|
||||
import mapJson from '/@/components/chinaMap/json/c';
|
||||
import { tabList, mapIcons, legendList } from './chinaHooks.ts';
|
||||
import { tabList, mapIcons, legendList, getTimeStr, getKmStr } from './chinaHooks.ts';
|
||||
import { message } from 'ant-design-vue';
|
||||
|
||||
const bgImg = new URL('/@/assets/images/china-textur.jpg', import.meta.url).href;
|
||||
@@ -226,6 +226,13 @@
|
||||
showRoutePanel.value = false;
|
||||
}
|
||||
|
||||
function setTitle({ time, distance }) {
|
||||
let str = '全程';
|
||||
str += getTimeStr(time);
|
||||
str += getKmStr(distance);
|
||||
panelTitle.value = str;
|
||||
}
|
||||
|
||||
function searchRoute() {
|
||||
showRoutePanel.value = false;
|
||||
panelTitle.value = '';
|
||||
@@ -256,46 +263,11 @@
|
||||
}
|
||||
});
|
||||
AMap.Event.addListener(driving, 'complete', (res) => {
|
||||
// console.log(JSON.stringify(res));
|
||||
const data = JSON.parse(JSON.stringify(res));
|
||||
console.log('data', data);
|
||||
if (data.info == 'OK') {
|
||||
const { routes } = data;
|
||||
const { distance, time } = routes[0];
|
||||
|
||||
function convertSeconds(seconds) {
|
||||
let hours = Math.floor(seconds / 3600);
|
||||
let minutes = Math.floor((seconds % 3600) / 60);
|
||||
let remainingSeconds = seconds % 60;
|
||||
|
||||
return {
|
||||
hours: hours,
|
||||
minutes: minutes,
|
||||
seconds: remainingSeconds,
|
||||
};
|
||||
}
|
||||
|
||||
function convertMetersToKilometers(meters) {
|
||||
var kilometers = meters / 1000;
|
||||
return Math.round(kilometers * 100) / 100;
|
||||
}
|
||||
|
||||
let str = '全程';
|
||||
const { hours, minutes } = convertSeconds(time);
|
||||
|
||||
if (hours) {
|
||||
str += hours + '小时';
|
||||
}
|
||||
if (minutes) {
|
||||
str += minutes + '分钟';
|
||||
}
|
||||
let d = convertMetersToKilometers(distance);
|
||||
let dr = d >= 1 ? d + '公里' : d * 100 + '米';
|
||||
str += `(${dr})`;
|
||||
console.log('str', str);
|
||||
panelTitle.value = str;
|
||||
setTitle(routes[0]);
|
||||
let arr = [];
|
||||
console.log('routes', routes);
|
||||
arr.push(data.originName);
|
||||
routes[0].steps.map((item) => {
|
||||
arr.push(item.instruction);
|
||||
|
||||
Reference in New Issue
Block a user