Issue
Currently I am using the following code to get the minimum and maximum latitude and longitude from a (Google Maps) MapView object.
GeoPoint center = map.getMapCenter();
Double minLat = (center.getLatitudeE6() - (map.getLatitudeSpan() / 2)) / 1E6;
Double minLong = (center.getLongitudeE6() - (map.getLongitudeSpan() / 2)) / 1E6;
Double maxLat = (center.getLatitudeE6() + (map.getLatitudeSpan() / 2)) / 1E6;
Double maxLong = (center.getLongitudeE6() + (map.getLongitudeSpan() / 2)) / 1E6;
Unfortunately, this is not giving me a correct output. I am currently at zoom level 18 in the MapView, centred on the point (52.9476, -1.1452). The output of the above code gives the values (52.947632, -181.145156, 52.947632, 178.854844) respectively. Obviously there is an issue here in that the minimum latitude shown is a physical impossibility, and the latitudes are both exactly the same as the centre latitude. I can confirm that the MapView itself is showing the location correctly.
Can anyone explain why this is happening? Of all the solutions to this issue I have seen, this is the only one that people seem to have had any luck with and it still doesn't work!
Solution
I've now solved this issue myself. Essentially, before the Projection of the MapView is ready, these functions will respectively return 0 and 360*1E6 for latitude and longitude. As such, all that needs to be done is in an AsyncTask perform checks on these values until they have been prepared.
Answered By - Tom Cameron
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.