-
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.
- Loading branch information
Showing
19 changed files
with
202 additions
and
111 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
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
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,3 @@ | ||
import Marker from './src/index.vue'; | ||
|
||
export default Marker; |
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,55 @@ | ||
<script setup lang="ts"> | ||
import { inject, markRaw, onBeforeUnmount, onMounted, provide, ref, unref, watch } from 'vue'; | ||
import type { MarkerClustererOptions } from '@googlemaps/markerclusterer'; | ||
import { MarkerClusterer, MarkerClustererEvents } from '@googlemaps/markerclusterer'; | ||
import { apiSymbol, mapSymbol, markerClustererSymbol } from '@/utlis/symbol'; | ||
const props = defineProps<MarkerClustererOptions>(); | ||
const emit = defineEmits<{ | ||
(e: 'clusteringbegin'): void | ||
(e: 'clusteringend'): void | ||
(e: 'click'): void | ||
}>(); | ||
const map = inject(mapSymbol, ref()); | ||
const api = inject(apiSymbol, ref()); | ||
const markerClusterer = ref<MarkerClusterer>(); | ||
const markerClustererEvents = Object.values(MarkerClustererEvents); | ||
provide(markerClustererSymbol, markerClusterer); | ||
onMounted(() => { | ||
watch(map, () => { | ||
if (map.value) | ||
markerClusterer.value = markRaw(new MarkerClusterer({ ...unref(props), map: map.value })); | ||
markerClustererEvents.forEach((event: any) => { | ||
markerClusterer.value?.addListener(event, () => emit(event)); | ||
}); | ||
markerClusterer.value?.render(); | ||
}, | ||
{ | ||
immediate: true, | ||
}); | ||
}); | ||
onBeforeUnmount(() => { | ||
if (markerClusterer.value) { | ||
api.value?.event.clearInstanceListeners(markerClusterer.value); | ||
markerClusterer.value.clearMarkers(); | ||
} | ||
}); | ||
defineExpose({ | ||
markerClusterer, | ||
}); | ||
</script> | ||
|
||
<template> | ||
<div class="marker-clusterer"> | ||
<slot /> | ||
</div> | ||
</template> |
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,9 +1,11 @@ | ||
import GoogleMap from './GoogleMap'; | ||
import MarkerClusterer from './MarkerClusterer'; | ||
import Marker from './Marker'; | ||
import InfoWindow from './InfoWindow'; | ||
|
||
export { | ||
GoogleMap, | ||
MarkerClusterer, | ||
Marker, | ||
InfoWindow, | ||
}; |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
import type { InjectionKey, Ref } from 'vue'; | ||
import type { MarkerClusterer } from '@googlemaps/markerclusterer'; | ||
import type { Map, Marker } from '../types'; | ||
|
||
export const mapSymbol: InjectionKey<Ref<Map | null>> = Symbol('map'); | ||
export const apiSymbol: InjectionKey<Ref<typeof google.maps | null>> = Symbol('api'); | ||
export const mapSymbol: InjectionKey<Ref<Map | undefined>> = Symbol('map'); | ||
export const apiSymbol: InjectionKey<Ref<typeof google.maps | undefined>> = Symbol('api'); | ||
export const markerClustererSymbol: InjectionKey<Ref<MarkerClusterer | undefined>> = Symbol('markerClusterer'); | ||
export const markerSymbol: InjectionKey<Ref<Marker | undefined>> = Symbol('marker'); |
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,12 +1,14 @@ | ||
<script setup lang="ts"> | ||
// import Basic from './components/BasicExample.vue'; | ||
// import Marker from './components/MarkerExample.vue'; | ||
import InfoWindow from './components/InfoWindowExample.vue'; | ||
// import MarkerClustererExample from './components/MarkerClustererExample.vue'; | ||
</script> | ||
|
||
<template> | ||
<!-- <Basic /> --> | ||
<!-- <Marker /> --> | ||
<InfoWindow /> | ||
<!-- <MarkerClustererExample /> --> | ||
</template> |
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.