Skip to content

incorrect zoom when turning the camera programmatically on the map #79

Description

@CTABPO

Hello.
When using a map with the camera's bearing in degrees parameter "initialCameraPosition: CameraPosition(target: ..., zoom: 16.0, heading: 62.0)" set, when the widget is being drawn, the zoom changes to a lower value. The soft zoom using the created zoom-in and zoom-out buttons does not work correctly. _controller.zoomIn() changes the zoom level with +0.01, and _controller.zoomOut() changes the zoom value with -2.0. there is no other way to rotate the map (specifically the map, not the camera's bearing), but there is a need to rotate the map, since it is necessary to display a certain area of the map with a certain rotation of the map, for a more comfortable user experience. when the map is rotated by the user's gestures, then the zoom works correctly.

// apple_maps_flutter: 1.4.0

// Flutter 3.29.2 • channel stable • https://github.com/flutter/flutter.git
// Framework • revision c236373904 (8 months ago) • 2025-03-13 16:17:06 -0400
// Engine • revision 18b71d647a
// Tools • Dart 3.7.2 • DevTools 2.42.3

// example

class _MapSampleState extends State<MapSample> {
  late final AppleMapController _controller;

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        AppleMap(
          initialCameraPosition: const CameraPosition(
            target: LatLng(37.768, -25.335),
            zoom: 16.0,
            heading: 62.0,
          ),
          onMapCreated: (AppleMapController controller) {
            _controller = controller;
          },
        ),
        Positioned(
          top: (Theme.of(context).bottomAppBarTheme.height ?? 80),
          right: 16.0,
          child: IconButton.filled(
              onPressed: () =>
                  _controller.animateCamera(CameraUpdate.zoomIn()),
              icon: const Icon(Icons.add)),
        ),
        Positioned(
          top: (Theme.of(context).bottomAppBarTheme.height ?? 80) + 40,
          right: 16.0,
          child: IconButton.filled(
              onPressed: () =>
                  _controller.animateCamera(CameraUpdate.zoomOut()),
              icon: const Icon(Icons.remove)),
        ),
      ],
    );
  }
}

Expected behavior : correct zoomIn and zoomOut

Tested on Simulator iPhone 12 17.4 and iPhone 13 18.4

flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.29.2, on macOS 26.1 25B78 darwin-arm64, locale ru-RU)
[!] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 26.1.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 2022.3)
[✓] VS Code (version 1.104.0)
[✓] Connected device (4 available)
[✓] Network resources

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions