How can I use high resolution custom markers with the scale parameter in Google's Static Maps API?
Asked Answered
Y

1

26

We're using Google's Static Maps API with the scale parameter to display lovely smooth maps for people using high resolution displays. However, we'd also like to use custom icons to show points on the map.

Unfortunately I can't find any way of doing this that doesn't give pixelated icons like in this example. Is there a way of doing this that doesn't scale the icons up?

Yam answered 26/4, 2012 at 15:32 Comment(5)
Have you looked at this #8813643 ?Pettifer
Yup. You'll notice that if you add &scale=2 to the end of that example URL then the icons become pixelated.Yam
why dont you use your own hd icon versions?Sportswoman
I'd love to, but when we add the scale parameter to the map the icons get scaled up by the same factor and become pixelated.Yam
@httpete Sadly not, and I'd still be interested if one was found.Yam
S
50

The &markers parameter now has an (undocumented) scale descriptor. Set that to 2 and the icon descriptor to your @2x marker image URL while using the &scale=2 parameter. Something like:

&markers=scale:2|[email protected]&scale=2

Source: https://groups.google.com/d/msg/google-maps-api/_METlecmeO4/JNyfkguoO7QJ

Stylite answered 16/6, 2013 at 5:9 Comment(10)
Not works for me. The map is retinified, but marker is not. Here is my url: maps.googleapis.com/maps/api/… , with the imgur.com/OEO1j4V.png for retina marker. But the map shows non-retina marker from imgur.com/QD06Ctj.png instead...Koestler
@Koestler Your marker image is too small -- imgur.com/OEO1j4V.png needs to be twice the size it currently is without losing image quality.Stylite
@Hakan B., imgur.com/OEO1j4V.png is actually a double-sized retina version, but API just uses non-retina imgur.com/QD06Ctj.png, despite the fact that I appended &markers=scale:2|icon=imgur.com/OEO1j4V.png&scale=2 to the end of URL...Koestler
And this is not because of imgur url redirects, I just tested it with self hosting markers on my own server. Seems like this undocumented feature is already gone...Koestler
@Koestler There are some formatting issues with your URL. Try this: maps.google.com/maps/api/…Stylite
Oh! I thought that I need to specify both non-retina and retina marker-urls in the final url, and API then will automatically use one or another depending on retina support. Thanks a lot for explaining!Koestler
This worked perfectly for standard icons, thanks! maps.googleapis.com/maps/api/…Ame
Life saver, but how on earth did you find this undocumented param?Rushing
Nice find, annoying that this is still undocumented and yet required.Cohn
Two years later and this is again, still not documentedSelangor

© 2022 - 2024 — McMap. All rights reserved.