自定义标记图标未显示Google Static Maps v2

max*_*ax_ 4 google-maps httprequest google-maps-static-api

我正在使用Static Google Maps API v2下载地图视图的静态图像,其中只有一个标记显示一个图像.但是,添加到markerurl参数的图像似乎没有任何区别,只是在该位置显示了一个红色标记.

请问你能告诉我哪里出错了?

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
Run Code Online (Sandbox Code Playgroud)

Sho*_*ari 17

您的图片网址必须删除字母S HTTPS安全网站,所以工作,例如:

http://foursquare.com/img/categories_v2/shops/financial_bg_64.png
Run Code Online (Sandbox Code Playgroud)

完整代码:

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
Run Code Online (Sandbox Code Playgroud)


小智 8

根据我的经验,http 或 https 没有这样的要求,只关心图标大小。图标大小不应超过 64X64 像素大小,静态地图将愉快地显示自定义图标。接受如果发现正确@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
Run Code Online (Sandbox Code Playgroud)

当然使用低于 64X64 尺寸的图像而不是

http://foursquare.com/img/categories_v2/shops/financial_64X64.png
Run Code Online (Sandbox Code Playgroud)

  • 如果它是关于 V3 API(问题是关于 V2)的,这应该是可接受的答案,至少对于典型的图标而言。http 和 https 在 V3 中都可以工作。文档模糊地表明最大尺寸是 4048(我以为它会缩小),但只有当我将图像尺寸减小到 64x64 时它才起作用。来自 API 文档:“图标最大尺寸可达 4096 像素(方形图像为 64x64)” (2认同)