我正在使用以下方法创建具有度数和/或微度数的 GeoPoints:
/**
* Create a {@link GeoPoint} from float values.
* @param lat Latitude as float
* @param lng Longitude as float
* @return {@link GeoPoint}
*/
public static GeoPoint createGeoPoint( double lat, double lng) {
return new GeoPoint(degreesToMicrodegrees(lat), degreesToMicrodegrees(lng));
}
/** Convert a float point degree value into a micro deree value */
public static int degreesToMicrodegrees( double deg ) {
return (int)(deg * 1E6);
}
这应该可以帮助你。
所以你的代码会是这样的:
public void onLocationChanged(Location loc) {
// TODO Auto-generated method stub
GeoPoint point = createGeoPoint(loc.getLatitude(),loc.getLongitude());
OverlayItem overlayitem = new OverlayItem(point, "My Current Location", "My Current Location");
overlay.addOverlay(overlayitem);
mapOverlays.add(overlay);
}