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

橙三吉。 提交于 2019-11-29 02:41:30

问题


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?


回答1:


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




回答2:


This is could be handy if you are using the API

var image = {
  url: place.icon,
  size: new google.maps.Size(71, 71),
  origin: new google.maps.Point(0, 0),
  anchor: new google.maps.Point(17, 34),
  scaledSize: new google.maps.Size(25, 25)
};

https://developers.google.com/maps/documentation/javascript/markers



来源:https://stackoverflow.com/questions/10336646/how-can-i-use-high-resolution-custom-markers-with-the-scale-parameter-in-google

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!