Skip to content

[google_maps_flutter] Strange issue when adding marker with some delay in IOS #169005

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Mohit8G opened this issue May 16, 2025 · 1 comment
Open
Labels
a: quality A truly polished experience found in release: 3.29 Found to occur in 3.29 found in release: 3.33 Found to occur in 3.33 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: maps Google Maps plugin P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@Mohit8G
Copy link

Mohit8G commented May 16, 2025

Steps to reproduce

Add large amount of marker on map and everything falls apart.

google_maps_flutter: ^2.10.0

Expected results

The markers should be plotted on given lat lng.

Actual results

the marker is plotted on given lat lng but also some random marker is added on map in case of ios

Code sample

Code sample
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

class GoogleMapIosIssue extends StatefulWidget {
  const GoogleMapIosIssue({super.key});

  @override
  State<GoogleMapIosIssue> createState() => _GoogleMapIosIssueState();
}

class _GoogleMapIosIssueState extends State<GoogleMapIosIssue> {
  Set<Marker> markers = {};
  late GoogleMapController _googleMapController;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GoogleMap(
        initialCameraPosition: const CameraPosition(
          target: LatLng(20.5937, 78.9629),
          zoom: 4,
        ),
        markers: markers,
        onMapCreated: onMapCreated,
      ),
    );
  }

  void onMapCreated(controller) {
    _googleMapController = controller;
    createItineraries();
    _generateMarkers(1000);
    setState(() {});
  }

  Future<void> createItineraries() async {
    final double minLat = 14.925;
    final double maxLat = 15.825;
    final double minLng = 73.675;
    final double maxLng = 74.215;

    final random = Random();

    for (int i = 0; i < 100; i++) {
      await Future.delayed(const Duration(milliseconds: 10));
      double lat = minLat + random.nextDouble() * (maxLat - minLat);
      double lng = minLng + random.nextDouble() * (maxLng - minLng);

      markers.add(
        Marker(markerId: MarkerId('marker11_$i'), position: LatLng(lat, lng), icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueYellow)),
      );
    }

    setState(() {});
  }


  final double minLat = 8.0;
  final double maxLat = 37.0;
  final double minLng = 68.0;
  final double maxLng = 97.0;

  void _generateMarkers(int count) {
    final random = Random();

    for (int i = 0; i < count; i++) {
      double lat = minLat + random.nextDouble() * (maxLat - minLat);
      double lng = minLng + random.nextDouble() * (maxLng - minLng);

      markers.add(
        Marker(
          markerId: MarkerId('marker_$i'),
          position: LatLng(lat, lng),
          icon: BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueMagenta),
        ),
      );
    }

    setState(() {});
  }
}

Screenshots or Video

Screenshots / Video demonstration We can see that in android marker are in one place but in ios marker are placed randomly on map Image Image

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.2, on macOS 14.3 23D56 darwin-arm64, locale en-IN)
    • Flutter version 3.22.2 on channel stable at /Users/mohit/.puro/envs/new/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 761747bfc5 (12 months ago), 2024-06-05 22:15:13 +0200
    • Engine revision edd8546116
    • Dart version 3.4.3
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/mohit/Library/Android/sdk
    • Platform android-35, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.7-11185874)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 15.4)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 15F31d
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2023.2)
    • 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 17.0.9+0-17.0.9b1087.7-11185874)

[✓] IntelliJ IDEA Ultimate Edition (version 2024.3.4.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • 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

[✓] Connected device (5 available)
    • sdk gphone64 arm64 (mobile)     • emulator-5554                        • android-arm64  • Android 15 (API 35) (emulator)
    • iPhone 15 Plus (mobile)         • 5B28CAA6-3AFA-4B69-9623-373D19D9B1AE • ios            • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 14.3 23D56 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 14.3 23D56 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 136.0.7103.114
    ! Error: Browsing on the local area network for iPhone - QA. Ensure the device is unlocked and attached with a cable or associated with the same local area network as
      this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)
    ! Error: Browsing on the local area network for Office - iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network
      as this Mac.
      The device must be opted into Developer Mode to connect wirelessly. (code -27)

[✓] Network resources
    • All expected network resources are available.

• No issues found!
@tirth-patel-nc tirth-patel-nc added the in triage Presently being triaged by the triage team label May 19, 2025
@tirth-patel-nc tirth-patel-nc changed the title [google_maps_flutter][IOS][HIGH PRIORITY] Strange issue when adding marker with some delay in IOS [google_maps_flutter][iOS] Strange issue when adding marker with some delay in IOS May 19, 2025
@tirth-patel-nc tirth-patel-nc changed the title [google_maps_flutter][iOS] Strange issue when adding marker with some delay in IOS [google_maps_flutter] Strange issue when adding marker with some delay in IOS May 19, 2025
@tirth-patel-nc
Copy link
Member

Triage Report

I was able to reproduce the issue using the provided code sample on both the stable (3.29.3) and master (3.33.0-1.0.pre.123) channels.

google_maps_flutter - 2.12.2

Android iOS
Screen.Recording.2025-05-19.at.2.59.30.PM.mov
Simulator.Screen.Recording.-.iPhone.16.Plus.-.2025-05-19.at.15.00.57.mp4
Code Sample (Same as OP)
import 'dart:async';
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

void main() => runApp(MaterialApp(home: const GoogleMapIosIssue()));

class GoogleMapIosIssue extends StatefulWidget {
  const GoogleMapIosIssue({super.key});

  @override
  State<GoogleMapIosIssue> createState() => _GoogleMapIosIssueState();
}

class _GoogleMapIosIssueState extends State<GoogleMapIosIssue> {
  Set<Marker> markers = {};

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: GoogleMap(
        initialCameraPosition: const CameraPosition(
          target: LatLng(20.5937, 78.9629),
          zoom: 4,
        ),
        markers: markers,
        onMapCreated: onMapCreated,
      ),
    );
  }

  void onMapCreated(controller) {
    createItineraries();
    _generateMarkers(1000);
    setState(() {});
  }

  Future<void> createItineraries() async {
    final double minLat = 14.925;
    final double maxLat = 15.825;
    final double minLng = 73.675;
    final double maxLng = 74.215;

    final random = Random();

    for (int i = 0; i < 100; i++) {
      await Future.delayed(const Duration(milliseconds: 10));
      double lat = minLat + random.nextDouble() * (maxLat - minLat);
      double lng = minLng + random.nextDouble() * (maxLng - minLng);

      markers.add(
        Marker(
          markerId: MarkerId('marker11_$i'),
          position: LatLng(lat, lng),
          icon: BitmapDescriptor.defaultMarkerWithHue(
            BitmapDescriptor.hueYellow,
          ),
        ),
      );
    }

    setState(() {});
  }

  final double minLat = 8.0;
  final double maxLat = 37.0;
  final double minLng = 68.0;
  final double maxLng = 97.0;

  void _generateMarkers(int count) {
    final random = Random();

    for (int i = 0; i < count; i++) {
      double lat = minLat + random.nextDouble() * (maxLat - minLat);
      double lng = minLng + random.nextDouble() * (maxLng - minLng);

      markers.add(
        Marker(
          markerId: MarkerId('marker_$i'),
          position: LatLng(lat, lng),
          icon: BitmapDescriptor.defaultMarkerWithHue(
            BitmapDescriptor.hueMagenta,
          ),
        ),
      );
    }

    setState(() {});
  }
}
stable (3.29.3) - flutter doctor -v
[✓] Flutter (Channel stable, 3.29.3, on macOS 15.4.1 24E263 darwin-arm64, locale
    en-IN) [970ms]
    • Flutter version 3.29.3 on channel stable at
      /Users/tirthpatel/Development/flutter_stable/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ea121f8859 (4 weeks ago), 2025-04-11 19:10:07 +0000
    • Engine revision cf56914b32
    • Dart version 3.7.2
    • DevTools version 2.42.3

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0)
    [855ms]
    • Android SDK at /Users/tirthpatel/Library/Android/sdk
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Applications/Android
      Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on
      this machine.
      To manually set the JDK path, use: `flutter config
      --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [556ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [9ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [9ms]
    • 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 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.99.3) [8ms]
    • 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) [5.5s]
    • macOS (desktop)                 • macos                 • darwin-arm64   •
      macOS 15.4.1 24E263 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad • darwin         •
      macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)                    • chrome                • web-javascript •
      Google Chrome 135.0.7049.115

[✓] Network resources [559ms]
    • All expected network resources are available.

• No issues found!
master (3.33.0-1.0.pre.123) - flutter doctor -v
[✓] Flutter (Channel master, 3.33.0-1.0.pre.123, on macOS 15.4.1 24E263 darwin-arm64, locale en-IN) [1,342ms]
    • Flutter version 3.33.0-1.0.pre.123 on channel master at /Users/tirthpatel/Development/flutter_master/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision e27377ef4d (11 hours ago), 2025-05-18 12:07:08 -0700
    • Engine revision e27377ef4d
    • Dart version 3.9.0 (build 3.9.0-138.0.dev)
    • DevTools version 2.46.0

[✓] Android toolchain - develop for Android devices (Android SDK version 36.0.0) [10.3s]
    • Android SDK at /Users/tirthpatel/Library/Android/sdk
    • Emulator version 35.4.9.0 (build_id 13025442) (CL:N/A)
    • Platform android-36, build-tools 36.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
      This is the JDK bundled with the latest Android Studio installation on this machine.
      To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
    • Java version OpenJDK Runtime Environment (build 21.0.6+-13355223-b631.42)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.3) [594ms]
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16E140
    • CocoaPods version 1.16.2

[✓] Chrome - develop for the web [7ms]
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2024.3) [7ms]
    • 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 21.0.6+-13355223-b631.42)

[✓] VS Code (version 1.100.2) [6ms]
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.110.0

[✓] Connected device (2 available) [5.6s]
    • macOS (desktop) • macos  • darwin-arm64   • macOS 15.4.1 24E263 darwin-arm64
    • Chrome (web)    • chrome • web-javascript • Google Chrome 136.0.7103.114

[✓] Network resources [448ms]
    • All expected network resources are available.

• No issues found!

@tirth-patel-nc tirth-patel-nc added platform-ios iOS applications specifically p: maps Google Maps plugin package flutter/packages repository. See also p: labels. team-ecosystem Owned by Ecosystem team has reproducible steps The issue has been confirmed reproducible and is ready to work on found in release: 3.29 Found to occur in 3.29 found in release: 3.33 Found to occur in 3.33 a: quality A truly polished experience team-ios Owned by iOS platform team and removed in triage Presently being triaged by the triage team team-ecosystem Owned by Ecosystem team labels May 19, 2025
@cbracken cbracken added P3 Issues that are less important to the Flutter project triaged-ios Triaged by iOS platform team labels May 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: quality A truly polished experience found in release: 3.29 Found to occur in 3.29 found in release: 3.33 Found to occur in 3.33 has reproducible steps The issue has been confirmed reproducible and is ready to work on p: maps Google Maps plugin P3 Issues that are less important to the Flutter project package flutter/packages repository. See also p: labels. platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy