25

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?

alnorth29
  • 3,525
  • 2
  • 34
  • 50

1 Answers1

49

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|icon=icon@2x.png&scale=2

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

Hakan B.
  • 2,319
  • 23
  • 29
  • Not works for me. The map is retinified, but marker is not. Here is my url: http://maps.googleapis.com/maps/api/staticmap?center=55.73376,37.346275&size=144x144&sensor=true&zoom=12&markers=icon:http://imgur.com/QD06Ctj.png%7C55.73076,37.346275&markers=scale:2|icon=http://imgur.com/OEO1j4V.png&scale=2 , with the http://imgur.com/OEO1j4V.png for retina marker. But the map shows non-retina marker from http://imgur.com/QD06Ctj.png instead... – Andrey Feb 14 '14 at 22:16
  • @Andrey Your marker image is too small -- imgur.com/OEO1j4V.png needs to be twice the size it currently is without losing image quality. – Hakan B. Feb 14 '14 at 22:28
  • @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=http://imgur.com/OEO1j4V.png&scale=2 to the end of URL... – Andrey Feb 14 '14 at 22:36
  • 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... – Andrey Feb 14 '14 at 22:57
  • 2
    @Andrey There are some formatting issues with your URL. Try this: https://maps.google.com/maps/api/staticmap?&markers=scale:2|icon:http://i.imgur.com/OEO1j4V.png|55.73376,37.346275|&size=144x144&sensor=true&zoom=12&scale=2& – Hakan B. Feb 14 '14 at 23:18
  • 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! – Andrey Feb 14 '14 at 23:37
  • This worked perfectly for standard icons, thanks! http://maps.googleapis.com/maps/api/staticmap?sensor=false&size=170x96&scale=2&zoom=10&center=Oslo&markers=scale:2|Oslo – Alastair Mar 26 '14 at 17:00
  • 3
    Life saver, but how on earth did you find this undocumented param? – Deminetix Apr 18 '14 at 05:12
  • 4
    Nice find, annoying that this is _still_ undocumented and yet required. – El Yobo Feb 09 '17 at 05:52
  • 2
    Two years later and this is again, still not documented – Josh Davenport-Smith Jan 17 '19 at 10:53