how to paint a referenced svg file as icon AdvancedMarkerElement (migratin Marker to AdvancedMarkerElement) [closed]

I’m migrating the markers objects of my app google map to AdvancedMarkerElement and the single marker is not being painted any suggestion of what I’m doing wrong?, I’ve visited this links tryin to clarify the execution

the glyphImg.src parameter is a vite reference to a svg file like this: /src/assets/Red Básica.svg Here is the two portions of the code involved ->

map.value = new Map(document.getElementById("googleMap") as HTMLElement, {
    mapId:'mapID',
    mapTypeControl: false,
    streetViewControl: false,
    zoomControl: false,
    fullscreenControl: false,
    center: geoLocation.value,
    mapTypeId: google.maps.MapTypeId.ROADMAP,
    zoom: 5,
    gestureHandling: "greedy"
});

const { AdvancedMarkerElement, PinElement } = (await google.maps.importLibrary("marker")) as google.maps.MarkerLibrary;
const glyphImg = document.createElement("img");
glyphImg.src = `${setIcon(localizaciones[0].icono)}`;
glyphImg.setAttribute("prv_codigo", String(localizaciones[0].prv_codigo));
const glyphSvgPinElement = new PinElement({ glyph: glyphImg });
const marker = new AdvancedMarkerElement({
    position: {
        lat: localizaciones[0].lat!,
        lng: localizaciones[0].lng!
    },
    map: map.value,
    title: localizaciones[0].prv_codigo ? String(localizaciones[0].prv_codigo) : String(localizaciones[0].idFerry),
    content: glyphSvgPinElement.element
});

  • 1

    And where’s your SVG? Please provide a minimal reproducible example that allows to reproduce the issue. Further to that, Google Maps official documentation has several examples on how to achieve this.

    – 

Leave a Comment