Android - how to get map coordinates from map view

In my application, I show places using markers on Google maps. But I immediately note all the available places that I do not want to do. I wanted to display places that just fit the screen, choosing the coordinates of the maps, as shown below:

enter image description here

I just wanted to select the places available in this range from the source by sending the coordinates of the maps. I'm not sure if I should capture all 4 coordinates from the corners of the screen?

Can someone help me figure this out?

+4
source share
4 answers

You can get them using this method:

yourMapView.getMap().getCameraPosition(); 

This returns a CameraPosition object. The coordinates of the camera are set by the target field and the zoom level on the scale field. Now you should be able to calculate the approximate coordinates of the corners of the screen.

+4
source

To get the coordinates of the TopLeft and BottomRight maps at any time, use the following:

 public GeoPoint getCurrentTL(MapView map){ Projection pr = map.getProjection(); return pr.fromPixels(0, 0); } public GeoPoint getCurrentBR(MapView map){ Projection pr = map.getProjection(); return pr.fromPixels(map.getWidth(), map.getHeight()); } 
+1
source

Otherwise, we can use LatLngBounds . It returns 2 points: northeast and southwest .

VisibleRegion vRegion = mMap.getProjection (). getVisibleRegion ();
LatLng southwest = vRegion.latLngBounds.southwest,
LatLng northeast = vRegion.latLngBounds.northeast;

https://developers.google.com/maps/documentation/android-api/views

+1
source

So this is an old question, but here is a fresh question.

You can request the visible area when the map is up (visible):

 VisibleRegion vRegion = mMap.getProjection().getVisibleRegion(); LatLng upperLeft = vRegion.farLeft LatLng lowerRight = vRegion.nearRight; 
0
source

All Articles