google-maps-markersangular-google-mapsangular11

@angular/google-maps Change marker color


I am using google-maps for Angular, and I can't find how to change the color of the marker. I have different coordinates and I wish to color each one separately.

For now I am using :

        const marker = {
      position: {
        lat: parseFloat(site.lat),
        lng: parseFloat(site.lng),
      },
      icon: "https://developers.google.com/maps/documentation/javascript/examples/full/images/beachflag.png",
      id: site.id,
      title: site.address,
      label: {
        color: 'red',
        text: site.contractCode,
      }
    };

I tried to pass an object with url attribute to icon, and a string, but none worked.

Thanks in advance


Solution

  • Can you use:

    <map-marker class="markerR" #marker="mapMarker" *ngFor="let unaalerta of listado"
                            [position]="unaalerta.Marker"
                            [options]="{icon: { url:'assets/images/{{unaalerta.icono}}' }, zIndex: 100}"