Repository: flutter
Issue: [google_maps_flutter] When drawing polygons, there is a lagging across the application.
Labels: c: performance,p: maps,package,perf: speed,team-ecosystem,has reproducible steps,P2,triaged-ecosystem,found in release: 3.24,found in release: 3.27

### Steps to reproduce

1. I defined my polygons list of type Set<Polygon> to the GoogleMap widget.
2. When the polygons data is completed, I update the state.
3. While drawing polygons, a lag occurs and lasts for a few seconds.

https://github.com/user-attachments/assets/d3f97724-bcc6-4d5b-839d-fcf182ca8044

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:ecommerce/constants/colors.dart';
import 'package:ecommerce/views/google_map/address/map_state.dart';
import 'package:ecommerce/widgets/page_appbar_widget.dart';
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:provider/provider.dart';
import 'package:url_launcher/url_launcher.dart';

class NewMapView extends StatefulWidget {
  const NewMapView({super.key});

  @override
  State<NewMapView> createState() => _NewMapViewState();
}

class _NewMapViewState extends State<NewMapView> {
  @override
  void initState() {
    context.read<MapState>().clearData();
    WidgetsBinding.instance.addPostFrameCallback((_) async {
      context.read<MapState>().setLoading(true);
      await context.read<MapState>().getPolygonList();
      await Future.delayed(const Duration(seconds: 2), () async {
        // if (mounted) await context.read<MapState>().showServiceAreas(mapController);
      });
    });
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: [
        Scaffold(
          appBar: const PageAppBarWidget(text: 'Teslimat Adresi'),
          body: GoogleMap(
            polygons: context.watch<MapState>().polygons,
            compassEnabled: false,
            zoomControlsEnabled: false,
            mapToolbarEnabled: false,
            trafficEnabled: false,
            buildingsEnabled: false,
            myLocationButtonEnabled: false,
            mapType: MapType.normal,
            onMapCreated: (GoogleMapController controller) {
              _controller = controller;
            },
            initialCameraPosition: const CameraPosition(
              target: LatLng(40.8010121, 29.3905112),
              zoom: 6.8,
            ),
          ),
        ),
        if (context.watch<MapState>().isLoading)
          const Dialog(
            backgroundColor: Colors.black45,
            insetPadding: EdgeInsets.zero,
            shape: Border(),
            child: Center(
              child: CircularProgressIndicator(
                color: ThemeColors.primaryColor,
              ),
            ),
          )
      ],
    );
  }
}
```

</details>


### What target platforms are you seeing this bug on?

Android, iOS

### OS/Browser name and version | Device information

iOS 18.1, iPhone 16 Pro Max

### Does the problem occur on emulator/simulator as well as on physical devices?

Yes

### Logs

<details open><summary>Logs</summary>

```console
[Paste your logs here]
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console
enescerrahoglu@192 DEV % flutter doctor -v
[✓] Flutter (Channel stable, 3.24.5, on macOS 15.1.1 24B91 darwin-arm64, locale tr-TR)
    • Flutter version 3.24.5 on channel stable at /Users/enescerrahoglu/development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision dec2ee5c1f (8 days ago), 2024-11-13 11:13:06 -0800
    • Engine revision a18df97ca5
    • Dart version 3.5.4
    • DevTools version 2.37.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/enescerrahoglu/development/sdk
    • Platform android-34, 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.6+0-17.0.6b829.9-10027231)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 16.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 16B40
    • CocoaPods version 1.15.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2022.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 17.0.6+0-17.0.6b829.9-10027231)

[✓] VS Code (version 1.95.3)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.100.0

[✓] Connected device (5 available)
    • Enes iPhone’u (mobile)          • 00008120-00142D511E04201E            • ios            • iOS 18.1 22B83
    • iPhone 16 Pro Max (mobile)      • 1B055A70-5EB8-483E-B63C-1897B4DC3247 • ios            • com.apple.CoreSimulator.SimRuntime.iOS-18-1 (simulator)
    • macOS (desktop)                 • macos                                • darwin-arm64   • macOS 15.1.1 24B91 darwin-arm64
    • Mac Designed for iPad (desktop) • mac-designed-for-ipad                • darwin         • macOS 15.1.1 24B91 darwin-arm64
    • Chrome (web)                    • chrome                               • web-javascript • Google Chrome 131.0.6778.85

[✓] Network resources
    • All expected network resources are available.

• No issues found!
```

</details>