Skip to content

Add pan animation #61

@EdHubbell

Description

@EdHubbell

This is a feature request. It'd be nice to have a .moveAnimated(center, zoom, ??).

Here's my terrible janky animation method at this time:

Future animateMapMove(MapController mapController, int msDelay, LatLng center) {
  mapController.move(center, 12.0);
  return new Future.delayed(Duration(milliseconds: msDelay), () => "1");
}

animateMapMove(store.state.mapController, 100, LatLng(startingPoint.latitude + 1* incLat, startingPoint.longitude + 1* incLon))
      .then( (t) => animateMapMove(store.state.mapController, 80, LatLng(startingPoint.latitude + 2* incLat, startingPoint.longitude + 2* incLon)))
      .then( (t) => animateMapMove(store.state.mapController, 30, LatLng(startingPoint.latitude + 3* incLat, startingPoint.longitude + 3* incLon)))
      .then( (t) => animateMapMove(store.state.mapController, 10, LatLng(startingPoint.latitude + 4* incLat, startingPoint.longitude + 4* incLon)))
      .then( (t) => animateMapMove(store.state.mapController, 10, LatLng(startingPoint.latitude + 5* incLat, startingPoint.longitude + 5* incLon)))
      .then( (t) => animateMapMove(store.state.mapController, 30, LatLng(startingPoint.latitude + 6* incLat, startingPoint.longitude + 6* incLon)))
      .then( (t) => animateMapMove(store.state.mapController, 80, LatLng(startingPoint.latitude + 7* incLat, startingPoint.longitude + 7* incLon)))
      .then( (t) => animateMapMove(store.state.mapController, 100, LatLng(startingPoint.latitude + 8* incLat, startingPoint.longitude + 8* incLon)))
      .then( (t) => animateMapMove(store.state.mapController, 100, action.mapCenter))
  ;

I'd like to be able to use Flutter's animation features, but I can't seem to figure out how to get a reference to vsync. I'm new to Flutter. I guess just about everyone is.

Here's some code that I was trying to use, but never got to go:

    final _latTween = new Tween<double>(begin: store.state.mapCenter.latitude, end: action.mapCenter.latitude);
    final _lngTween = new Tween<double>(begin: store.state.mapCenter.longitude, end: action.mapCenter.longitude);

    AnimationController controller;
    Animation<double> animation;

    // I can't figure out how to get a vsync in here. Might work if I could.
    controller = new AnimationController(duration: const Duration(milliseconds: 2000), vsync:);
    animation = new CurvedAnimation(parent: controller, curve: Curves.easeIn);

    controller.addListener(() {
      store.state.mapController.move(LatLng(_latTween.evaluate(animation), _lngTween.evaluate(animation)), 12.0);
    });

    controller.forward();

I'm not sure if we'd pass an AnimationController to the MapController, or vice-versa, or what.

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature[DEPRECATED] This issue requests a new feature

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions