1
votes

With Google Maps, how do you add a label to a custom marker when loading a static map via URL?

https://maps.googleapis.com/maps/api/staticmap?size=970x485&scale=2&markers=label:A|scale:2|icon:http://example.com/icon.png|48.1363,11.5749|48.1363,10.5749|48.1363,12.5749

This URL does not work.

Additionally, I would like to have different labels for different markers, but specify only one icon.

1

1 Answers

3
votes

You can only label your markers using alphanumeric characters. First, note that your query does not work because you are using an unreachable icon in your query. I you just use the following query:

https://maps.googleapis.com/maps/api/staticmap?size=970x485&scale=2&markers=label:A|scale:2|48.1363,11.5749|48.1363,10.5749|48.1363,12.5749

you can achieve this: aMarkers

And adding different label for each marker: aMarkers

On the other hand, you can have a custom icon, like this red cat:

catMarkers

note: this is the transformation to encode the url of the icon:
icon url: http://i.imgur.com/T7Q1dCN.png
icon url-encoded: |icon:http%3A%2F%2Fi.imgur.com%2FT7Q1dCN.png

Please note that only Google's built-in markers allow the label parameter. If you want to use custom label with custom letters, just create them as a png image, upload them and use them :D