I studied this on Google and SO, but I'm stuck, I think I don't have something fundamental. Most of the examples that I saw are not related to an arbitrary mapWidth and one point, but simply to the Overlay range.
I have a database of map points, MapView and Geocoder . I can find the zip code in my application and have the Address returned by my Geocoder .
Using this Address , I can build a GeoPoint and search in my database and return a list of nearby points. The problem is an attempt to scale using a span built from the returned Address point and the distance to the nearest point in the database.
I want the range to cover the next two points (if available). Here is the relevant code:
Collections.sort(listingDisplay, mComparator); listingDisplayAdapter.notifyDataSetChanged(); float spanWidth =0; if (listingDisplay.size() > 1) { spanWidth = (float) (2 * distanceFromPoint(listingDisplay.get(1), current)); } else if (listingDisplay.size() == 1) { spanWidth = (float) (2 * distanceFromPoint(listingDisplay.get(0), current)); } Log.v(TAG, "SpanWidth: " + spanWidth);
ListingDisplay contains a list of nearest points with the mComparator comparator, sorting this list with the closest locations to my returned Address ( GeoPoint called: current ) at the top of the list.
Then I set the spanWidth value based on the closest value and try to figure out the range from that.
My question is: how can I build a span from a given distance and center point ?
source share