wachunei
wachunei

Reputation: 51

Android MapView MapController stopAnimation not stopping animation

well, i'm developing a geolocation app in Android. On first run we center the map at the current location, then the user can zoom and pan freedomly, but we have a button that animates the map and centers it back to the actual position.

The problem is that this just happens when the map is static: if the user scrolls the map and leaves it scrolling by inertia, this button won't work until the animation is stopped.

Here's the code.

mapView.getController().stopAnimation(false); //this aint working as expected
mapView.getController().animateTo(myLocationOverlay.getMyLocation());

Thanks.

Upvotes: 2

Views: 424

Answers (1)

Howard Hodson
Howard Hodson

Reputation: 943

This works for me:

public void centerCurrentClickHandler(View v) {
    if (hasCurrentPosition) {
        GeoPoint point = new GeoPoint(currentLatitudeE6, currentLongitudeE6);
        mapController.animateTo(point);
    }
}

public void centerFlagClickHandler(View v) {
    if (hasPushpinPosition) {
        GeoPoint point = new GeoPoint(pushpinLatitudeE6, pushpinLongitudeE6);
        mapController.animateTo(point);
    }
}

Upvotes: 1

Related Questions