Angular-google-maps: How to change angular 2 google map marker label color?

Created on 26 Sep 2017  路  12Comments  路  Source: SebastianM/angular-google-maps

Issue description
hello I am using Angular2 Google Maps and i want change my maker label color

code :

<agm-map [zoom]="7" [latitude]="lat" [longitude]="lng" [styles]='[
            {
                elementType : "labels.text",
                stylers : [{
                   color:"#ffffff"
                }]
            }]'> <agm-marker>....</agm-marke>

but its set google default label color
please help me ...

Most helpful comment

You can modify the colour of the marker but passing in properties into the marker itself.

[label]="labelOptions"

TS:

labelOptions = {
color: '#CC0000',
fontFamily: '',
fontSize: '14px',
fontWeight: 'bold',
text: 'Some Text',
}

All 12 comments

You can modify the colour of the marker but passing in properties into the marker itself.

[label]="labelOptions"

TS:

labelOptions = {
color: '#CC0000',
fontFamily: '',
fontSize: '14px',
fontWeight: 'bold',
text: 'Some Text',
}

@MattPua hello your code working but problem is here

label text is dynamic from for loop.... how to set text from for loop

solved by change css : .gm-style div{color: #fff !important; font-weight: bold;}

@snd1890
Can you share "...." , i want edit icon same you ,thanks!!

@MattPua - It would be great if you can share how to change the label background color? Like this.

markerlabel

If we could also change the position that would be great. A few styles are ignored - backgroundColor and marginTop specifically.

Alternatively, give the div a class name so we can access it with CSS

@Ashokrlz did you find out how to make that change?

Anyone has idea how to change marker image?

I'm using https://developers.google.com/chart/image/docs/gallery/dynamic_icons#icon_types. So just use [iconUrl] param and change it on hover to the icon with text for example like I did

You can use the answer from @MattPua and send a dynamic text, like this:

[label]="{
    color: '#ffffff',
    fontWeight: 'bold',
    text: (i + 1).toString()
}"

@Viktor-Bredihin Could you give an example of how you achieved this?

this simple style works for me to style agm marker label
<agm-map style="text-shadow: 0px 0px 6.2px grey;"> <agm-marker *ngFor="let device of devices" [label]="'anything'"></agm-marker> </agm-map>

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Halynsky picture Halynsky  路  3Comments

maneesht picture maneesht  路  3Comments

n1t3w0lf picture n1t3w0lf  路  3Comments

dineshkumar20 picture dineshkumar20  路  3Comments

gnujeremie picture gnujeremie  路  3Comments