开发者

convert LatLng into Pixel compatible to Android Screen

I have a google map image in which a location for example "New York" is marked & i have converted its latitude and longitude i开发者_运维知识库nto 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.


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).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜