Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update usage of useMapsLibrary in AdvancedMarker #55

Merged
merged 1 commit into from
Nov 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/components/advanced-marker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function useAdvancedMarker(props: AdvancedMarkerProps) {
useState<HTMLDivElement | null>(null);

const map = useContext(GoogleMapsContext)?.map;
const markersLibraryReady = useMapsLibrary('marker');
const markerLibrary = useMapsLibrary('marker');

const {
children,
Expand All @@ -69,9 +69,9 @@ function useAdvancedMarker(props: AdvancedMarkerProps) {

// create marker instance and add it to the map when map becomes available
useEffect(() => {
if (!map || !markersLibraryReady) return;
if (!map || !markerLibrary) return;

const newMarker = new google.maps.marker.AdvancedMarkerElement();
const newMarker = new markerLibrary.AdvancedMarkerElement();
newMarker.map = map;

setMarker(newMarker);
Expand All @@ -91,7 +91,7 @@ function useAdvancedMarker(props: AdvancedMarkerProps) {
setMarker(null);
setContentContainer(null);
};
}, [map, markersLibraryReady, numChilds]);
}, [map, markerLibrary, numChilds]);

// bind all marker events
useEffect(() => {
Expand Down