0

look at this:

MyLocationOverlay myLocationOverlay = new MyLocationOverlay(this, mapView);


    myLocationOverlay.enableMyLocation();
    myLocationOverlay.enableCompass();
    GeoPoint myGeoPoint = myLocationOverlay.getMyLocation();

That works fine. But i need to save the coordinates in a variable. So i tried this:

myLocationLon = (double) myGeoPoint.getLongitudeE6();

When i run the App, this last line makes it collapse. Can you please tell me why this doesn't work ? Thank you

1 Answer 1

0

GeoPoint.getLongitudeE6() and GeoPoint.getLatitudeE6() both return microdegrees (basically degrees * 1E6).

so you need to convert microdegrees to degrees simply write function:

public double microDegreesToDegrees(int microDegrees) {
    return microDegrees / 1E6;
}

and then

myLocationLon = microDegreesToDegrees(myGeoPoint.getLongitudeE6());
4
  • Thx, but that doesn't seem to to work. The last line causes a collapse when i try to start the app. Jun 12, 2012 at 15:11
  • post your logcat that would certainly help to solve the issue.
    – Vipul
    Jun 12, 2012 at 15:12
  • I think the problem is, that a value for the Longitude isn't existing yet, when I call your function. Here a screen: www1.xup.in/exec/ximg.php?fid=35589012 Jun 12, 2012 at 15:16
  • myLocationLon = (myGeoPoint.getLongitudeE6() / 1E6); //doesn't work Jun 12, 2012 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.