6
votes

I have a google map image in which a location for example "New York" is marked & i have converted its latitude and longitude into pixel , using javascript example of Google Map Javascript API V3 click

but the problem is ANCHOR_OFFSET_ as i want the pixel to be converted according to Android screen. so basically what i am trying to implement is if i have location (lat , lng ) - on google map image - i want to convert it into (X,Y) co-ordinates of android screen.

1

1 Answers

9
votes

If your using a MapView then you can call something like:

//Get map projection
Projection projection = mapView.getProjection();

//Convert LatLng to on screen location
Point p1 = new Point();
//projection.toPixels(gp, p1);
p1 = projection.toScreenLocation(location);

where location is a LatLng. resulting with point p1 containing the screen location, the screen location is in screen pixels (not display pixels) relative to the top left of the map (not of the whole screen).