-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3a6099
commit 996c61c
Showing
15 changed files
with
473 additions
and
37 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
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,28 @@ | ||
import { Ref, ref, shallowRef } from 'vue'; | ||
import { useGlobalState } from '../../utils/store'; | ||
|
||
type ImageProps = { | ||
coordinates: [number, number]; // [lat, lng] | ||
annotation: mapkit.ImageAnnotationConstructorOptions; | ||
}; | ||
|
||
export const ImageAnnotation = (props: ImageProps): void => { | ||
const state = useGlobalState(); | ||
const mapkit: Ref<typeof window.mapkit> = shallowRef(state.mapkit.value); | ||
|
||
if (state.mapLoad && state.map.value) { | ||
const coords = new mapkit.value.Coordinate( | ||
props.coordinates[0], | ||
props.coordinates[1], | ||
); | ||
const annotation: Ref<mapkit.ImageAnnotationConstructorOptions> = ref( | ||
props.annotation, | ||
); | ||
|
||
const imageAnnotation = new mapkit.value.ImageAnnotation( | ||
coords, | ||
annotation.value, | ||
); | ||
state.map.value.addAnnotation(imageAnnotation); | ||
} | ||
}; |
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,27 @@ | ||
import { Ref, ref, shallowRef } from 'vue'; | ||
import { useGlobalState } from '../../utils/store'; | ||
|
||
type MarkerProps = { | ||
coordinates: [number, number]; // [lat, lng] | ||
annotation?: mapkit.MarkerAnnotationConstructorOptions; | ||
}; | ||
|
||
export const MarkerAnnotation = (props: MarkerProps): void => { | ||
const state = useGlobalState(); | ||
const mapkit: Ref<typeof window.mapkit> = shallowRef(state.mapkit.value); | ||
|
||
if (state.mapLoad && state.map.value) { | ||
const coords = new mapkit.value.Coordinate( | ||
props.coordinates[0], | ||
props.coordinates[1], | ||
); | ||
const annotation: Ref<mapkit.MarkerAnnotationConstructorOptions> = ref( | ||
props.annotation || {}, | ||
); | ||
const markerAnnotation = new mapkit.value.MarkerAnnotation( | ||
coords, | ||
annotation.value, | ||
); | ||
state.map.value.addAnnotation(markerAnnotation); | ||
} | ||
}; |
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,2 @@ | ||
export { ImageAnnotation } from './Image'; | ||
export { MarkerAnnotation } from './Marker'; |
Oops, something went wrong.