Getting the pixel co-ordinates of a Google map marker

安稳与你 提交于 2020-01-14 22:48:45

问题


Is it possible to determine the pixel co-ordinates of a given marker, taking into account current zoom level and visible area of the map?


回答1:


Current (v3):

map.getProjection().fromLatLngToPoint(marker.position);

https://developers.google.com/maps/documentation/javascript/3.exp/reference#Projection

Old (v2):

The method fromLatLngToContainerPixel following should give you what you're after, assuming markerPoint is your marker, and zoomLevel your current zoom:

map.fromLatLngToContainerPixel(markerPoint.getLatLng(), zoomLevel);


来源:https://stackoverflow.com/questions/1553064/getting-the-pixel-co-ordinates-of-a-google-map-marker

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