| | |
| | | <template> |
| | | <div class="relative"> |
| | | <div class="relative bg-white"> |
| | | <div ref="containerRef" class="h-full"></div> |
| | | <div ref="infoWindowRef" v-show="infoWindowIsShow"> |
| | | <div |
| | |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <LayerControl v-if="olMap" :olMap="olMap" class="absolute top-3 left-10 z-10" /> |
| | | <LayerControl v-if="olMap" :olMap="olMap" class="absolute top-3 left-3 z-10" /> |
| | | </div> |
| | | </template> |
| | | |
| | |
| | | import equipSelectPic from './img/equip-select.svg'; |
| | | import equipPic from './img/equip.svg'; |
| | | import LayerControl from './LayerControl.vue'; |
| | | import { OLMap } from '/@/model/map/OLMap'; |
| | | import { GaoDeSourceType, OLMap } from '/@/model/map/OLMap'; |
| | | |
| | | const props = defineProps<{ |
| | | data: any; |
| | | }>(); |
| | | const props = withDefaults( |
| | | defineProps<{ |
| | | data: any; |
| | | config?: { |
| | | sourceType: GaoDeSourceType; |
| | | markerIsVisible: boolean; |
| | | }; |
| | | }>(), |
| | | { |
| | | config: () => ({ |
| | | sourceType: GaoDeSourceType.Vector, |
| | | markerIsVisible: true, |
| | | }), |
| | | } |
| | | ); |
| | | const colsArray = computed(() => { |
| | | return props.data.cols ?? []; |
| | | }); |
| | |
| | | }; |
| | | const showInfoWindow = (overlay: Overlay) => { |
| | | const position = overlay.getPosition(); |
| | | const row = overlay.get('extData'); |
| | | const row = overlay.get('extData')?.value; |
| | | if (!row) return; |
| | | lastOverlay && setMarkerIcon(lastOverlay, equipPic); |
| | | infoWindowIsShow.value = true; |
| | | infoWindowOverlay.setPosition(position); |
| | |
| | | const addMarkerLayer = () => { |
| | | const map = props.data.map; |
| | | if (map.pos_x == null && map.pos_y == null) return; |
| | | |
| | | const dataList = (props.data?.values ?? []).map((item) => { |
| | | const x = item[map.pos_x]; |
| | | const y = item[map.pos_y]; |
| | |
| | | return { |
| | | position: [x, y], |
| | | // textColor: item.color, |
| | | extData: item, |
| | | title: item.title, |
| | | extData: { |
| | | value: item, |
| | | recordSetTable: props.data, |
| | | }, |
| | | }; |
| | | }); |
| | | olMap.value.addMarkerLayer(dataList, { |
| | |
| | | size: 30, |
| | | selectUrl: equipSelectPic, |
| | | }, |
| | | click(e, label, item, position) { |
| | | click(e, label, extData, position) { |
| | | showInfoWindow(label); |
| | | }, |
| | | }, |
| | |
| | | const initMap = () => { |
| | | olMap.value = new OLMap({ |
| | | container: containerRef.value, |
| | | sourceType: props.config?.sourceType, |
| | | markerIsVisible: props.config?.markerIsVisible, |
| | | }); |
| | | addMarkerLayer(); |
| | | infoWindowOverlay = olMap.value.createEleOverlay(infoWindowRef.value); |
| | | olMap.value.map.addOverlay(infoWindowOverlay); |
| | | }; |
| | | |
| | | defineExpose({ |
| | | olMap: olMap, |
| | | }); |
| | | |
| | | onMounted(() => { |
| | | initMap(); |
| | | }); |