views:

31

answers:

1

Hi,

Using Google Maps on Android does anyone have any ideas on how to load only markers that would be displayed on the current screen?

I'm thinking about sending a request to a web service that returns the lat/lng for the relevant markers. But what would the parameters be that I could use to calculate if a given lat/lng is within the screen?

What would be perfect would be something like Gowalla's implementation:

http://gowalla.com/api/explorer#/spots?lat=30.2697&lng=-97.7494&radius=50

Any ideas?

Mike

A: 

I'm working on an app that needs to do some similar things, here is my suggestion (my app is SDK Level 7)

In my example below, mapView is an object of type MapView

mapView.getLatitudeSpan();

Returns: The current latitude span (from the top edge to the bottom edge of the map) in decimal degrees multiplied by one million.

and

mapView.getLongitudeSpan();

Returns: The current longitude span (from the left edge to the right edge of the map) in decimal degrees multiplied by one million.

Here are another three helpful methods.

mapView.getLocationInWindow(location);
mapView.getLocationOnScreen(location);
mapView.getZoomLevel();
Eric