Search code examples
javascriptgoogle-mapsgoogle-maps-api-3projection

How to call fromLatLngToDivPixel in Google Maps API V3?


I know that method exists and is documented, but I don't know how to get an MapCanvasProjection object.


Solution

  • Look at http://qfox.nl/notes/116

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

    Ugly indeed. Much easier in v2 - another flaw of google api v3!