Get coordinate values from myLocationOverlay in Android
I have an app that uses a map to show a certain, fixed, location. With the next update I'd like to show the route from the users current location to this fixed point. I already managed to get the users location via myLocationOverlay.
As far as I see it I need to send the coordinates to Google Maps, receive a .kml file with the points and draw the route from that. How can I get the values for latitude and longitude from myLoc开发者_StackOverflow社区ationOverlay or is there a better way to do what I want to do? TIAYou can use getMyLocation from MyLocationOverlay
. You then need to convert the GeoPoint
into its respective degree for lat and long.
Here is a reference for Geo.java that contains some of the function that you could use to convert the GeoPoint
to its corresponding lat and longitude. In particular you want to use these two:
public static Location toLocation(GeoPoint point) {
Location result = new Location("");
result.setLatitude(toDegrees(point.getLatitudeE6()));
result.setLongitude(toDegrees(point.getLongitudeE6()));
return result;
}
And
/**
* Convert microdegrees to degrees.
* @param degreesE6 Value in microdegrees.
* @return Value in degrees.
*/
public static double toDegrees(int degreesE6) {
return (double) degreesE6 / E6;
}
精彩评论