1
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

5
  • what even is markerLibrary? where does it come from? reading the documentation, it seems you may want to const { AdvancedMarkerElement } = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary; Commented Jun 20 at 16:21
  • yes I have that. I haven't errors in console. when I use the mode deprecated it was ok but AdvancedMarkerElement not drawing pin inside modal but outside it's work ok. i try any different types modal. Commented Jun 21 at 4:10
  • yes I have that. if you have that, then why are you using new markerLibrary!.AdvancedMarkerElement instead of just new AdvancedMarkerElement - nothing in what you posted even hints at what markerLibrary is, so Commented Jun 21 at 4:13
  • the library "marker" it was loaded async when onMounted and assign in a var. it's an example: const marker = await google.maps.importLibrary("marker") as google.maps.MarkerLibrary; markerLibrary = marker ; Commented Jun 21 at 4:33
  • Fair enough, seems odd you'd import maps one way and marker a different way - makes the code in the question harder to analyse, since you just use the markerLibrary 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 Commented Jun 21 at 4:44

0