Google maps api v3: top and left marker pixel position

I want to get the top and left marker position (in pixels) in google map api v3. How can this be done? I know there are some tips for using fromLatLngToDivPixel() , but can I know how this works? Example?

+4
source share
2 answers

Do you mean the coordinates in pixels inside the div? Take a look at http://qfox.nl/notes/116

 overlay = new google.maps.OverlayView(); overlay.draw = function() {}; overlay.setMap(map); var point = overlay.getProjection().fromLatLngToContainerPixel(latLng); 

or

 var point = overlay.getProjection().fromLatLngToDivPixel(latLng); 

Ugly. Much easier in v2, where these methods were directly methods of the GMap2 object. Another google api v3 error!

+5
source

If you encounter an undefined overlay problem, this is because the object is created after the idle map.

Better call it in the event listener, the full explanation is here fooobar.com/questions/744818 / ...

+1
source

Source: https://habr.com/ru/post/1382543/


All Articles