Repository: flutter
Issue: [google_maps_flutter] [iOS] Stop Animation of Marker when it changed
Labels: platform-ios,p: maps,package,has reproducible steps,P2,found in release: 3.10,team-ios,triaged-ios,found in release: 3.13

### Is there an existing issue for this?

- [X] I have searched the [existing issues](https://github.com/flutter/flutter/issues)
- [X] I have read the [guide to filing a bug](https://flutter.dev/docs/resources/bug-reports)

### Steps to reproduce

1. when I changed the location of the marker it animated and did not reach immediately real time .
2. i have poly line but the polyline can reach the location immediately 
3.  it's just happened in the ios version

### Expected results

I want to stop animating the marker when it changed, I don't know what to do because the Android version it doesn't seem like IOS [just only ios has the animating marker]

### Actual results

the marker had have animation when it changed the location [only ios]

### Code sample

<details><summary>Code sample</summary>

```dart

class MyTravelGoogleMap extends StatefulWidget {
  final List<HistoryModel> listHistory;
  final StreamController<int> indexController;
  final StreamController<bool> canDrawLineControl;
  final bool canMoveCamera;

  const MyTravelGoogleMap(
      {Key? key,
      required this.listHistory,
      required this.indexController,
      required this.canDrawLineControl,
      required this.canMoveCamera})
      : super(key: key);

  @override
  _MyTravelGoogleMapState createState() => _MyTravelGoogleMapState();
}

class _MyTravelGoogleMapState extends State<MyTravelGoogleMap> {
  // Marker? _userMarker;
  Completer<GoogleMapController> _controller = Completer();
  final _listDrawLine = <int>[];
  List<LatLng> listLatLng = [];

  @override
  void initState() {
    listLatLng = widget.listHistory.map((history) => history.latLng).toList();
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) async {
      await _onMoveCamera();
      // _onDrawLine();
    });
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    final provider = InitProvider.initListen(context);
    final size = SizeScreen(context);

    return StreamBuilder<Position>(
        stream: Geolocator.getPositionStream(),
        initialData: provider.positionInit,
        builder: (_, position) {
          return StreamBuilder<int>(
              stream: widget.indexController.stream,
              initialData: 0,
              builder: (_, indexHistory) {
                // if (_listDrawLine.contains(indexHistory.data?.toInt() ?? 0)) {
                //   // debugPrint("BACKWARD ${index.toInt()}");
                //   _listDrawLine.remove(indexHistory.data?.toInt() ?? 0);
                // } else {
                //   // debugPrint("FORWARD ${index.toInt()}");
                //   _listDrawLine.add(indexHistory.data?.toInt() ?? 0);
                //   _listDrawLine.toSet().toList();
                // }
                final intDrawList = List.generate(
                    (indexHistory.data ?? 0) > 0
                        ? ((indexHistory.data ?? 0) + 1)
                        : 0,
                    (index) => index);
                final drawList = intDrawList
                    .map((e) => widget.listHistory[e].latLng)
                    .toList();
                return StreamBuilder<bool>(
                    stream: widget.canDrawLineControl.stream,
                    initialData: true,
                    builder: (_, canDraw) {
                      return GoogleMap(
                        mapType: MapType.normal,
                        onMapCreated: (map) {
                          _controller.complete(map);
                        },
                        polylines: {
                          // _polyDrawLine(latLngList: listDraw),
                          if (canDraw.data ?? false)
                            _polyDrawLine(latLngList: drawList),
                          if (!(canDraw.data ?? false))
                            _polyline(latLngList: listLatLng),
                        },
                        markers: {
                          _arrowMarker(
                              latLng: widget
                                  .listHistory[indexHistory.data!.toInt()]
                                  .latLng,
                              rotation: (widget
                                  .listHistory[indexHistory.data!.toInt()]
                                  .azimuth
                                  .toDouble())),
                          _userMarker(position: position.data!),
                          _startFlagMarker(latLng: listLatLng.first),
                          _endFlagMarker(latLng: listLatLng.last),
                        },
                        initialCameraPosition: CameraPosition(
                          target: listLatLng.first,
                          zoom: 14.4746,
                        ),
                      );
                    });
              });
        });
  }

  // void _onDrawLine() {
  //   widget.indexController.stream.listen((index) {
  //     if (_listDrawLine.contains(index.toInt())) {
  //       debugPrint("BACKWARD ${index.toInt()}");
  //       _listDrawLine.remove(index.toInt());
  //     } else {
  //       debugPrint("FORWARD ${index.toInt()}");
  //       _listDrawLine.add(index.toInt());
  //       _listDrawLine.toSet().toList();
  //     }
  //     setState(() {});
  //   });
  // }

  Future<void> _onMoveCamera() async {
    final GoogleMapController controller = await _controller.future;

    widget.indexController.stream.listen((index) async {
      if (widget.canMoveCamera) {
        if ((index % 7) == 0) {
          controller.animateCamera(CameraUpdate.newLatLngZoom(
              widget.listHistory[index.round()].latLng, 14));
        }
      }
    });
  }

  Polyline _polyDrawLine({required List<LatLng> latLngList}) {
    final size = SizeScreen(context);

    return Polyline(
        polylineId: const PolylineId("DrawLine"),
        points: latLngList,
        color: const Color(0xffD68401),
        width: size.h015 ~/ 2);
  }

  Polyline _polyline({required List<LatLng> latLngList}) {
    final size = SizeScreen(context);

    return Polyline(
        polylineId: const PolylineId("All The way line"),
        points: latLngList,
        color: const Color(0xff43E53C),
        width: size.h015 ~/ 2);
  }

  Marker _userMarker({required Position position}) {
    final pin = InitProvider.initNoListen(context).pinMapModel!;
    return Marker(
        markerId: MarkerId("_userMarker"),
        icon: pin.userPin,
        position: LatLng(position.latitude, position.longitude),
        infoWindow: InfoWindow(title: "You are here!"));
  }

  Marker _startFlagMarker({required LatLng latLng}) {
    final pin = InitProvider.initNoListen(context).pinMapModel!;
    return Marker(
        markerId: MarkerId("_startFlagMarker"),
        icon: pin.flagStartPin,
        position: latLng,
        infoWindow: InfoWindow(title: "Start From here!"));
  }

  Marker _endFlagMarker({required LatLng latLng}) {
    final pin = InitProvider.initNoListen(context).pinMapModel!;
    return Marker(
        markerId: MarkerId("_endFlagMarker"),
        icon: pin.flagEndPin,
        position: latLng,
        infoWindow: InfoWindow(title: "End to here!"));
  }

  Marker _arrowMarker({required LatLng latLng, required double rotation}) {
    final pin = InitProvider.initNoListen(context).pinMapModel!;
    return Marker(
        markerId: MarkerId("_arrowMarker"),
        icon: pin.arrow,
        rotation: rotation,
        flat: true,
        position: latLng,
        anchor: const Offset(0.5, 0.5),
        infoWindow: InfoWindow(title: "End to here!"));
  }
}
```

</details>


### Screenshots or Video

<details>
<summary>Screenshots / Video demons


</summary>

https://github.com/flutter/flutter/assets/58029766/bbb815f3-e07a-4113-8191-71d89e465b0d

</details>
[](url)

### Logs

<details><summary>Logs</summary>

```console
not have console log
```

</details>


### Flutter Doctor output

<details><summary>Doctor output</summary>

```console
[!] Flutter (Channel stable, 3.10.4, on macOS 13.4.1 22F82 darwin-arm64, locale en-GB)
    • Flutter version 3.10.4 on channel stable 
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 682aa387cf (3 weeks ago), 2023-06-05 18:04:56 -0500
    • Engine revision 2a3401c9bb
    • Dart version 3.0.3
    • DevTools version 2.23.1
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
    • Android SDK at 
    • Platform android-33, build-tools 31.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS (Xcode 14.3.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14E300c
    ✗ CocoaPods not installed.
        CocoaPods is used to retrieve the iOS and macOS platform side's plugin code that responds to your plugin usage on the Dart side.
        Without CocoaPods, plugins will not work on iOS or macOS.
        For more info, see https://flutter.dev/platform-plugins
      To install see https://guides.cocoapods.org/using/getting-started.html#installation for instructions.

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2020.3)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)

[✓] VS Code (version 1.79.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension can be installed from:
      🔨 https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter

[✓] Connected device (3 available)
    • macOS (desktop)          • macos                     • darwin-arm64   • macOS 13.4.1 22F82 darwin-arm64
    • Chrome (web)             • chrome                    • web-javascript • Google Chrome 114.0.5735.198

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 2 categories.
Process finished with exit code 0```

</details>