Custom Marker Icon not showing Google Static Maps v2
Asked Answered
A

3

5

I am using the Static Google Maps API v2 to download a static image of a map view with a singular marker just showing one image. However, the image added to the marker parameter of the url doesn't seem to be making any difference, and just a red marker is shown at the location.

Please can you tell me where I am going wrong?

http://maps.googleapis.com/maps/api/staticmap
?center=37.446754,-77.572746
&size=70x61
&maptype=roadmap
&sensor=true
&scale=2
&zoom=15
&key=some_key
&markers=icon:https://foursquare.com/img/categories_v2/shops/financial_bg_64.png|37.446754,-77.572746
Albaugh answered 7/9, 2012 at 20:33 Comment(0)
D
19

your image URL must remove the letter S HTTPS secure site, so work, for example like this:

http://foursquare.com/img/categories_v2/shops/financial_bg_64.png

complete code:

http://maps.googleapis.com/maps/api/staticmap?
center=37.446754,-77.572746&size=70x61&maptype=roadmap&sensor=false
&scale=2&zoom=15
&markers=icon:http://foursquare.com/img/categories_v2/shops/financial_bg_64.png|37.446754,-77.572746
Dogwood answered 7/9, 2012 at 20:52 Comment(1)
Are you saying that HTTPS is not support for icons?Bubonocele
F
10

In my experience, There is no such requirement of http or https just care for icon size . icon size should not exceed more than 64X64 pixels in size , Static map will happily show the custom icon . accept if found correct @max_

http://maps.googleapis.com/maps/api/staticmap?
center=37.446754,-77.572746&size=70x61&maptype=roadmap&sensor=false
&scale=2&zoom=15
&markers=icon:http://foursquare.com/img/categories_v2/shops/financial_64X64.png|37.446754,-77.572746

off course use your image with below 64X64 dimension instead of

http://foursquare.com/img/categories_v2/shops/financial_64X64.png
Furore answered 24/1, 2018 at 12:41 Comment(2)
Thank you. 64x64. Wow. Not mentioned on this page at all: developers.google.com/maps/documentation/maps-static/introNebo
This should be the accepted answer if it were about the V3 API (question is about V2), at least for typical icons. Both http and https work in V3. The documentation vaguely suggest that the maximum size is 4048 (I assumed it would scale down for me), but it worked only when I reduced the image size to 64x64. From the API doc: Icons may be up to 4096 pixels maximum size (64x64 for square images)Aerodyne
B
2

You're actually not doing anything wrong, it's Google to blame:

"The Google Static Maps API does not support custom icon URLs that use HTTPS"

Bubonocele answered 17/12, 2015 at 6:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.