let markerLibrary: google.maps.MarkerLibrary | null = null
let placesLibrary: google.maps.PlacesLibrary | null = null
let mapLibrary: google.maps.MapsLibrary | null = null
const marker = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
markerLibrary = marker
const { Map } = await google.maps.importLibrary('maps') as google.maps.MapsLibrary
const center = new google.maps.LatLng(43.2955357,-2.8849016)
mapInstance.value = new Map(elMap,{
zoom: 16,
mapId: 'DEMO_MAP_ID',
center,
disableDefaultUI: true
})
const marker = new markerLibrary!.AdvancedMarkerElement({
position: center,
map: mapInstance.value,
//zIndex: 99999999,
})
/*
/* success but this is deprecated
new markerLibrary.Marker({
map: mapInstance.value,
position: center
}) */
not throwing error display in console browser. outside of modal it's work correctly
I'm try deprecated metod of .Marker() and work correctly
markerLibrary
? where does it come from? reading the documentation, it seems you may want toconst { AdvancedMarkerElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary;
yes I have that.
if you have that, then why are you usingnew markerLibrary!.AdvancedMarkerElement
instead of justnew AdvancedMarkerElement
- nothing in what you posted even hints at whatmarkerLibrary
is, somaps
one way andmarker
a different way - makes the code in the question harder to analyse, since you just use themarkerLibrary
variable with absolutely no context to what it actually is. Perhaps you should add your previous comment INTO the question so that others won't need to ask so many questions to understand your code