-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding map component and update recording
- Loading branch information
1 parent
75477e1
commit f9ffb82
Showing
8 changed files
with
206 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.DS_Store | ||
/**/*.shp | ||
/**/*.shx |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<!-- eslint-disable @typescript-eslint/no-explicit-any --> | ||
<script lang="ts"> | ||
import { defineComponent, PropType, Ref, ref } from "vue"; | ||
import useState from "../use/useState"; | ||
import { watch } from "vue"; | ||
import geo, { GeoEvent } from "geojs"; | ||
|
||
export default defineComponent({ | ||
name: "MapLocation", | ||
components: {}, | ||
props: { | ||
editor: { | ||
type: Boolean, | ||
default: true, | ||
}, | ||
size: { | ||
type: Object as PropType<{ width: number; height: number }>, | ||
default: () => ({ width: 300, height: 300 }), | ||
}, | ||
location: { | ||
type: Object as PropType<{ x?: number; y?: number } | undefined>, | ||
default: () => undefined, | ||
}, | ||
}, | ||
emits: ['location'], | ||
setup(props, { emit }) { | ||
const mapRef: Ref<HTMLDivElement | null> = ref(null); | ||
const map: Ref<any> = ref(); | ||
const mapLayer: Ref<any> = ref(); | ||
const markerLayer: Ref<any> = ref(); | ||
const markerFeature: Ref<any> = ref(); | ||
const markerLocation: Ref<{ x: number; y: number } | null> = ref(null); | ||
watch(mapRef, () => { | ||
if (mapRef.value) { | ||
const usCenter = { x: -90.5855, y: 39.8333 }; | ||
const centerPoint = props.location && props.location.x && props.location.y ? props.location : usCenter; | ||
const zoomLevel = props.location && props.location.x && props.location.y ? 6 : 3; | ||
map.value = geo.map({ node: mapRef.value, center: centerPoint, zoom: zoomLevel }); | ||
mapLayer.value = map.value.createLayer("osm"); | ||
markerLayer.value = map.value.createLayer("feature", { features: ["marker"] }); | ||
markerFeature.value = markerLayer.value.createFeature("marker"); | ||
if (props.location?.x && props.location?.y) { | ||
markerLocation.value = { x: props.location?.x, y: props.location.y }; | ||
markerFeature.value | ||
.data([markerLocation.value]) | ||
.style({ | ||
symbol: geo.markerFeature.symbols.drop, | ||
symbolValue: 1 / 3, | ||
rotation: -Math.PI / 2, | ||
radius: 30, | ||
strokeWidth: 5, | ||
strokeColor: "blue", | ||
fillColor: "yellow", | ||
rotateWithMap: false, | ||
}) | ||
.draw(); | ||
} | ||
if (props.editor) { | ||
mapLayer.value.geoOn(geo.event.mouseclick, (e: GeoEvent) => { | ||
// Place a marker at the point | ||
const { x, y } = e.geo; | ||
markerLocation.value = { x, y }; | ||
markerFeature.value | ||
.data([markerLocation.value]) | ||
.style({ | ||
symbol: geo.markerFeature.symbols.drop, | ||
symbolValue: 1 / 3, | ||
rotation: -Math.PI / 2, | ||
radius: 30, | ||
strokeWidth: 5, | ||
strokeColor: "blue", | ||
fillColor: "yellow", | ||
rotateWithMap: false, | ||
}) | ||
.draw(); | ||
emit('location', { lon: x, lat:y }); | ||
|
||
}); | ||
} | ||
} | ||
}); | ||
return { | ||
mapRef, | ||
}; | ||
}, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<v-card class="pa-0 ma-0"> | ||
<div ref="mapRef" :style="`width:${size.width}px; height:${size.height}px`" /> | ||
</v-card> | ||
</template> | ||
|
||
<style lang="scss" scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.