1

Using MyLocationNewOverlay I can show user's current location in my mapview.

 mylocation = new MyLocationNewOverlay(mapView);
            mylocation.enableMyLocation();
            mylocation.enableFollowLocation();
            IMyLocationProvider s= mylocation.getMyLocationProvider();
            mylocation.getMyLocation();
            mapView.getOverlays().add(mylocation);

To create a route, I've tried to get user's current location by mylocation.getMyLocation /mylocation.getLastFix() but both return null. How to retrive the geopoint/lat long points?

user232803
  • 365
  • 6
  • 19

1 Answers1

1

If you used mylocation.getMyLocation() and it returned null it's because you didn't leaved it enough time to find your location.

If we take a look at the source code here:

public GeoPoint getMyLocation() {
    if (mLocation == null) {
        return null;
    } else {
        return new GeoPoint(mLocation);
    }
}

You get null simply because your location is actually null, same goes for mylocation.getLastFix()

public Location getLastFix() {
    return mLocation;
}

Make sure you wait at least for runOnFirstFix to end before trying to get your location.

Also, the line:

IMyLocationProvider s= mylocation.getMyLocationProvider();

is unnecessary in this context, aside from that, you should be on the right track.

M. Haché
  • 354
  • 6
  • 17