Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get the long & lat value of four corners in the mapview in android?

i working on map view. i want to put overlay item on the map view. that overlay items are all depends on currently showing map view and zoom level. how to get current map view's longitude and latitude of that four corner and how to analyze how many overlay item inside it. also we have to check thee zoom level.Any Idea? how to do it?

like image 666
Praveen Avatar asked Mar 19 '10 10:03

Praveen


2 Answers

If you're using the google-play-services library and the SupportMapFragment in particular.

this.getMap() will give you the instance of GoogleMap (which wraps MapView)

Then just:

map.getProjection().getVisibleRegion();

like image 84
yarian Avatar answered Oct 18 '22 11:10

yarian


I think you have to use

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

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

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

like image 27
Sephy Avatar answered Oct 18 '22 09:10

Sephy