-1

ここに私が持っている次のコードがありますが、エラーがあります。誰かが助けることができますか?

public void onLocationChanged(Location loc) {
        // TODO Auto-generated method stub
        GeoPoint point = new GeoPoint(loc.getLatitude(),loc.getLongitude());
        OverlayItem overlayitem = new OverlayItem(point, "My Current Location", "My Current Location");
        overlay.addOverlay(overlayitem);
        mapOverlays.add(overlay);

    }
4

3 に答える 3

6

実際には、GeoPoint座標をマイクロ度で保存するため、変換Locationするには次のGeoPointコードを使用します。

GeoPoint point = new GeoPoint((int)(loc.getLatitude() * 1E6), (int)(loc.getLongitude() * 1E6));

お役に立てれば

于 2012-07-25T10:32:32.597 に答える
1

度やマイクロ度を使用してGeoPointを作成するには、次のように使用しています。

/**
 * 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);

}
于 2012-07-25T10:32:57.353 に答える
0
GeoPoint pointRabat = new GeoPoint(microDegres(latitude),
                microDegres(longitude));
        mapController.setCenter(pointRabat);


    private int microDegres(double value) {
        return (int) (value * 1000000);
    }
于 2012-07-25T10:40:56.160 に答える