Agm-marker label

Максим Попов picture Максим Попов · Mar 13, 2018 · Viewed 13k times · Source

How to styling agm-marker-label - max-width for set text to center ? I can change label position but can't set min-width for centralization label name.

<agm-marker *ngIf="school.lat && school.lng" 
                    [iconUrl]="{url: school.mapMarker, scaledSize: {height: 75,width: 48},labelOrigin:{x:70,y:20}}"
                    [label]="{text:school.schoolName}"
                    [longitude]="school.lng | parseFloat"
                    [latitude]="school.lat | parseFloat">
        </agm-marker>

Answer

Shadi S picture Shadi S · Oct 20, 2018

using 2 [label] attributes didn't work for me. Instead the following worked:

<agm-marker
        *ngFor="let sp of mySPlist"
        [latitude]="sp.geoLat" [longitude]="sp.geoLon"
        [iconUrl]="sp.icon"
        [label]="{color: 'white', text: sp.name}"
      >
</agm-marker>