How to get long & lat value of four angles in mapview in android?

i is working on a map view. I want to overlay the map. that the overlay elements all depend on how the map view and zoom level are currently displayed. how to get the current map of longitude and latitude of this quadrangle and how to analyze how many overlay elements are inside it. we also need to check the zoom level. Any idea? how to do it?

+7
android google-maps android-mapview
source share
3 answers

I think you should use

mapview.getProjection().frompixel(intx, int y) 

For 4 corners of the screen (you can get their coordinates in width and getheight on your mapView and starting from (0,0), (getwidth (), 0), (0, getheight ()) and (getwidth (), getheight ())

This will give you 4 geototes from which you can extract latitude and longitude

+11
source share

Are you looking for something like this?

 Projection proj = mapView.getProjection(); GeoPoint topLeft = proj.fromPixels(0, 0); GeoPoint bottomRight = proj.fromPixels(mapView.getWidth()-1, mapView.getHeight()-1); double topLat = topLeft.getLatitudeE6()/1E6; double topLon = topLeft.getLongitudeE6()/1E6; double bottomLat = bottomRight.getLatitudeE6()/1E6; double bottomLon = bottomRight.getLongitudeE6()/1E6; 

Hope this helps!

+6
source share

If you use google-play-services SupportMapFragment and SupportMapFragment in particular.

this.getMap() will provide you with an instance of GoogleMap (which wraps MapView )

Then just:

map.getProjection().getVisibleRegion();

+6
source share

All Articles