3

As far as I understand, jQuery cannot read Google Maps data. So is there a pure javascript way to get marker coordinates relative to the screen? (top(), left()). Thanks.

EDIT: Projection class did this via toScreenLocation() method in API v2, but how would I achieve the same in v3 ?

EDIT 2: I am using WebView from Android SDK to load the map.

For answer see this: https://stackoverflow.com/a/6671206/997633

Community
  • 1
  • 1
astralmaster
  • 2,344
  • 11
  • 50
  • 84

1 Answers1

0

Maybe try this?

var point;
var pointIWant = projection.fromLatLngToPoint(marker.getPosition(), point);

According to the Google Maps API docs, google.maps.Projection.fromLatLngToPoint() converts a latitude/longitude coordinate to a point on the screen.

Eric Hydrick
  • 3,467
  • 2
  • 28
  • 41
  • weird but it doesn't work. It returns undefined on pintIWant even though I have an eventistener for the map to finish loading. (idle) – astralmaster Feb 19 '13 at 16:56
  • 1
    instead, i was able to get the desired result with fromLatLngToContainerPixel() method – astralmaster Feb 19 '13 at 16:56
  • 1
    projection.fromLatLngToPoint converts from LatLng to world coordinates (also known as the point plane). It doesn't give you any reference as to how this point relates to the current viewport. – Chad Killingsworth Feb 19 '13 at 21:46