|
@@ -69,7 +69,7 @@
|
|
|
v-for="(item, index) in routeData"
|
|
|
:key="index"
|
|
|
:class="index === selectIndex ? 'route-item2 route-item2-active' : 'route-item2'"
|
|
|
- @click="drawRoute(item)"
|
|
|
+ @click="drawRoute(item, index)"
|
|
|
>
|
|
|
<div class="text-box1">
|
|
|
<div :class="'tag tag' + index">{{ getTag(index) }}</div>
|
|
@@ -103,6 +103,14 @@ import { getEmergencyRescuePointInfoList } from '@/api/globalMap';
|
|
|
import markImg from '@/assets/images/map/mark.png';
|
|
|
import startImg from '@/assets/images/map/start.png';
|
|
|
import endImg from '@/assets/images/map/end.png';
|
|
|
+import gcoord from 'gcoord';
|
|
|
+import Icon from 'ol/style/Icon';
|
|
|
+import Feature from 'ol/Feature';
|
|
|
+import Point from 'ol/geom/Point';
|
|
|
+import Style from 'ol/style/Style';
|
|
|
+import { LineString } from 'ol/geom';
|
|
|
+import { Stroke } from 'ol/style';
|
|
|
+import useMapStore from '@/store/modules/map';
|
|
|
|
|
|
interface Props {
|
|
|
location?: string | number[];
|
|
@@ -111,22 +119,16 @@ interface Props {
|
|
|
const AMapType = ['vectorgraph', 'satellite'];
|
|
|
const props = withDefaults(defineProps<Props>(), {});
|
|
|
const { proxy } = getCurrentInstance() as ComponentInternalInstance;
|
|
|
-const { emergency_resource, disaster_relief_material } = toRefs<any>(proxy?.useDict('emergency_resource', 'disaster_relief_material'));
|
|
|
-import gcoord from 'gcoord';
|
|
|
-import Icon from 'ol/style/Icon';
|
|
|
-import Feature from 'ol/Feature';
|
|
|
-import Point from 'ol/geom/Point';
|
|
|
-import Style from 'ol/style/Style';
|
|
|
-import { LineString } from 'ol/geom';
|
|
|
-import { Stroke } from 'ol/style';
|
|
|
+const { disaster_relief_material } = toRefs<any>(proxy?.useDict('disaster_relief_material'));
|
|
|
|
|
|
+const mapStore = useMapStore();
|
|
|
const amapKey = 'e45d4caa2bef3c84714a2ed9b1e27d98';
|
|
|
let getMapUtils = inject('getMapUtils');
|
|
|
let showAddress = ref(true);
|
|
|
let routeData = ref([]);
|
|
|
let routeLine, startMarker, endMarker;
|
|
|
let routesAddress = ref('');
|
|
|
-let AMap, map, geocoder;
|
|
|
+let AMap, map;
|
|
|
let eventList = ref([]);
|
|
|
let selectData = ref({
|
|
|
event_title: '',
|
|
@@ -149,6 +151,7 @@ let total = ref(0);
|
|
|
let dataList = ref([]);
|
|
|
const toSelect = () => {
|
|
|
map.on('click', handleClickMap);
|
|
|
+ mapStore.setIsMapSelect(true);
|
|
|
showAddress.value = false;
|
|
|
routeData.value = [];
|
|
|
clearMarker();
|
|
@@ -160,6 +163,7 @@ const handleClickMap = (e) => {
|
|
|
} else {
|
|
|
map.un('click', handleClickMap);
|
|
|
}
|
|
|
+ mapStore.setIsMapSelect(false);
|
|
|
getAddress([e.lnglat.getLng(), e.lnglat.getLat()]);
|
|
|
};
|
|
|
const confirmSelect = () => {
|
|
@@ -223,6 +227,44 @@ const selectEvent = (item, unFitView) => {
|
|
|
}
|
|
|
getList();
|
|
|
};
|
|
|
+const createMarks = (item, unFitView) => {
|
|
|
+ clearMarker();
|
|
|
+ if (AMapType.includes(props.activeMap)) {
|
|
|
+ // 以 icon URL 的形式创建一个途经点
|
|
|
+ const icon = new AMap.Icon({
|
|
|
+ size: new AMap.Size(19, 31),
|
|
|
+ image: markImg
|
|
|
+ });
|
|
|
+ selectMarker = new AMap.Marker({
|
|
|
+ position: new AMap.LngLat(item.longitude, item.latitude),
|
|
|
+ icon: icon,
|
|
|
+ offset: new AMap.Pixel(-13, -30)
|
|
|
+ });
|
|
|
+ selectMarker.setMap(map);
|
|
|
+ if (!unFitView) {
|
|
|
+ map.setFitView([selectMarker]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const icon = new Icon({
|
|
|
+ src: markImg,
|
|
|
+ width: 19,
|
|
|
+ height: 31
|
|
|
+ });
|
|
|
+ const feature = new Feature({
|
|
|
+ geometry: new Point([item.longitude, item.latitude])
|
|
|
+ });
|
|
|
+ feature.setStyle(
|
|
|
+ new Style({
|
|
|
+ image: icon
|
|
|
+ })
|
|
|
+ );
|
|
|
+ const vectorLayer = getMapUtils().getVectorLayer();
|
|
|
+ vectorLayer.getSource().addFeature(feature);
|
|
|
+ if (!unFitView) {
|
|
|
+ map.getView().setCenter([item.longitude, item.latitude]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+};
|
|
|
let selectIndex = ref(-1);
|
|
|
const handleRoutes = async (item) => {
|
|
|
selectIndex.value = -1;
|
|
@@ -405,6 +447,7 @@ const getAddress = async (location) => {
|
|
|
if (result.status === '1' && result.regeocode) {
|
|
|
tempState.address = result.regeocode.formatted_address;
|
|
|
}
|
|
|
+ createMarks({ longitude: location[0], latitude: location[1] }, true);
|
|
|
};
|
|
|
const clearMarker = () => {
|
|
|
if (!selectMarker) return;
|
|
@@ -571,6 +614,7 @@ onMounted(() => {
|
|
|
align-items: center;
|
|
|
padding: 7px 0;
|
|
|
border-bottom: 1px solid #4574d5;
|
|
|
+ cursor: pointer;
|
|
|
.text-box2 {
|
|
|
.text2 {
|
|
|
font-size: 14px;
|