Reputation: 35
I am currently developing an android project which needs to place on a map (created from Google Maps Android API v2) markers for every place which is currently positioned in the map field of view.
I'm using a database on a windows azure server and I'm obtaining all the records that have the latitude and longitude inside a circle with origin in device location and the radius being the distance for the center to a corner/side of the phone.
How can I obtain the distance for the center of the map to a side? And how to convert it into decimal degrees?
Upvotes: 1
Views: 1742
Reputation: 22603
You can fetch the LatLngBounds from the Map
LatLngBounds bounds = mMap.getProjection().getVisibleRegion().latLngBounds;
Using the northeast
and the southwest
corner of the bound you should be able to query your DB to only select the markers you're interested in.
You can also check if a marker is within that LatLngBounds
bounds.contains(yourLatLngFromAzure)
yourLatLngFromAzure is a com.google.android.gms.maps.model.LatLng
Upvotes: 2