Skip to content

[google_maps_flutter] Add Advanced Markers support #7882

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
wants to merge 136 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
136 commits
Select commit Hold shift + click to select a range
43e7f4b
Use local package version for development
aednlaxer Sep 24, 2024
1df604c
Add advanced markers classes and capability check
aednlaxer Sep 24, 2024
b5a762f
Simplify BitmapDescriptor creation from PinConfig
aednlaxer Sep 25, 2024
f6aaeed
Add advanced markers clustering
aednlaxer Sep 25, 2024
d21efda
Add AdvancedMarkers example
aednlaxer Sep 25, 2024
590bd73
Add documentation
aednlaxer Sep 26, 2024
967e35a
Move advanced markers page to main example
aednlaxer Sep 27, 2024
a452546
Add Advanced Markers support for web
aednlaxer Sep 30, 2024
5032d5a
Add opacity and visibility support. Restore legacy markers icon custo…
aednlaxer Sep 30, 2024
01ee12d
Change example pages to use AdvancedMarkers
aednlaxer Sep 30, 2024
7ebbbf1
Deprecate cloudMapId and use mapId instead
aednlaxer Sep 30, 2024
d9476bc
Fix marker update
aednlaxer Oct 1, 2024
9760db8
Fix draggable flag
aednlaxer Oct 1, 2024
f184b04
Fix cloudMapId deprecation on iOS
aednlaxer Oct 1, 2024
509c87c
Fix cloudMapId deprecation on Android
aednlaxer Oct 1, 2024
a82416c
Convert Android example to use Advanced Markers
aednlaxer Oct 1, 2024
42a5d55
Add missing public member documentation
aednlaxer Oct 1, 2024
7142a23
Add cloudMapId to make MapConfiguration backward-compatible
aednlaxer Oct 2, 2024
1432fec
Add AdvancedMarker tests
aednlaxer Oct 2, 2024
57ab8bf
Fix web integration tests
aednlaxer Oct 2, 2024
a026e31
Add actual capability check on web
aednlaxer Oct 2, 2024
8e7269a
Add AdvancedMarker test
aednlaxer Oct 2, 2024
16c790f
Add marker type to MapWidgetConfiguration
aednlaxer Oct 3, 2024
d1e1918
Use legacy markers for all examples. Add separate Advanced Marker exa…
aednlaxer Oct 3, 2024
9f9572c
Add advanced marker examples for Android
aednlaxer Oct 4, 2024
26c1493
Add capability check (iOS)
aednlaxer Oct 7, 2024
abed4b3
Add collision behavior support
aednlaxer Oct 7, 2024
9f7f624
Remove isAdvanced flag from AdvancedMarker class
aednlaxer Oct 9, 2024
cde0ca1
Remove isAdvanced flag from AdvancedMarker on Android
aednlaxer Oct 9, 2024
63c0d43
Add AdvancedMarker examples (iOS)
aednlaxer Oct 9, 2024
b847bc0
Fix Android and iOS tests
aednlaxer Oct 11, 2024
f26c3b8
Use enum instead of boolean to indicate that marker is advanced
aednlaxer Oct 14, 2024
c6115e2
Add more tests
aednlaxer Oct 15, 2024
005785f
Rename MarkerType enum values
aednlaxer Oct 15, 2024
0ecffad
Add a comment about hue bitmap descriptor
aednlaxer Oct 15, 2024
5b61f58
Fix after rebase
aednlaxer Oct 16, 2024
be481c7
Update README
aednlaxer Oct 16, 2024
065bdd1
Clean up
aednlaxer Oct 16, 2024
a0d9e31
Reformat code
aednlaxer Oct 16, 2024
dbebe95
Fix lint issue
aednlaxer Oct 17, 2024
ff474bd
Add license blocks
aednlaxer Oct 17, 2024
588c689
Add advanced markers sample to readme_sample.dart
aednlaxer Oct 17, 2024
29e8447
Fix bitmap test timeout
aednlaxer Oct 17, 2024
f12f8b2
Fix incorrect enum value
aednlaxer Oct 17, 2024
fc28825
Move README sample to a separate file
aednlaxer Oct 18, 2024
ec63890
Update excerpts
aednlaxer Oct 18, 2024
3201e5d
Bump min web version
aednlaxer Oct 21, 2024
1fb6122
Treat innerHTML as JSAny
aednlaxer Oct 21, 2024
20189e5
Squashed commit of the following:
aednlaxer Dec 12, 2024
a4e36c1
Fix merge issues on iOS
aednlaxer Dec 12, 2024
2da7188
Fix merge issues on Android
aednlaxer Dec 12, 2024
cf7866b
Fix comments
aednlaxer Dec 12, 2024
d4980e1
Make mapId not global (examples)
aednlaxer Dec 13, 2024
25c3ea6
Rename getSelectedMarker to copyWithSelectedStated
aednlaxer Dec 13, 2024
09a2976
Remove cloudMapId field
aednlaxer Dec 13, 2024
0473454
Make offsetToJson private
aednlaxer Dec 13, 2024
ea564e9
Convert Glyph class to 3 different bitmap descriptor classes
aednlaxer Dec 16, 2024
bfa5b44
Remove cloudMapId field
aednlaxer Dec 16, 2024
5e66578
Assert that (legacy) marker's icon is not a PinConfig
aednlaxer Dec 16, 2024
a9261a3
Update PinConfig examples
aednlaxer Dec 16, 2024
fe2475f
Move MarkerType to MapConfiguration
aednlaxer Dec 19, 2024
b2d67c5
Fix marker type in platform implementation
aednlaxer Dec 19, 2024
dee79af
Remove cluster renderer check
aednlaxer Dec 19, 2024
6b0cff2
Add comment for isAdvancedMarkersAvailable
aednlaxer Dec 19, 2024
7302630
Squashed commit of the following:
aednlaxer Dec 20, 2024
6b5a36b
Fix merge issues
aednlaxer Dec 23, 2024
0e83e45
Revert unwanted changes
aednlaxer Dec 23, 2024
6a71b68
Tweak README content
aednlaxer Jan 10, 2025
8ae1124
Add cloudMapId getter
aednlaxer Jan 10, 2025
0a4f69f
Return false from isAdvancedMarkersAvailable
aednlaxer Jan 10, 2025
8c04fd2
Make AdvancedMarkerGlyph sealed
aednlaxer Jan 10, 2025
71d0089
Revert cloudMapId serialization
aednlaxer Jan 10, 2025
1b09b09
Update mapId comment
aednlaxer Jan 13, 2025
653b80d
Fix method name typo
aednlaxer Jan 17, 2025
b744a8e
Add GoogleMapMarkerType enum to the user-facing package
aednlaxer Jan 17, 2025
e677409
Fix test
aednlaxer Jan 17, 2025
6f58a7f
Use collection-if in advanced_marker.dart
aednlaxer Jan 17, 2025
3ad9d5f
Use double-slash comments
aednlaxer Jan 17, 2025
f1b42c1
Use gmaps.Size instead of Size
aednlaxer Jan 17, 2025
b7e4cd1
Add advanced marker rotation
aednlaxer Jan 20, 2025
ad5f11e
Use Object instead of dynamic
aednlaxer Jan 20, 2025
17c7320
Split controllers based on marker type
aednlaxer Jan 20, 2025
3d41dbe
Use Object? instead of dynamic
aednlaxer Jan 20, 2025
529b44a
Use _marker everywhere in MarkerController
aednlaxer Jan 20, 2025
c216632
Get rid of _getOnMarkerType
aednlaxer Jan 20, 2025
c12484d
Make T extend JSObject
aednlaxer Jan 20, 2025
5046e62
Update advanced marker examples
aednlaxer Jan 21, 2025
a1edc55
Help web integration tests pass.
ditman Feb 5, 2025
11a0cab
Convert marker to options before calling createMarkerController
aednlaxer Feb 5, 2025
80bce38
Fix unit tests
aednlaxer Feb 5, 2025
68af80c
Reformat code
aednlaxer Feb 5, 2025
c2c4021
Update excerpts
aednlaxer Feb 5, 2025
ee690ce
Fix iOS tests
aednlaxer Feb 5, 2025
75e7b2f
Fix README example
aednlaxer Feb 12, 2025
9ee8857
Fix force unwrap in advanced markers clustering example
aednlaxer Feb 12, 2025
3a28f2e
Clean up imports
aednlaxer Feb 12, 2025
b283e3e
Add missing comment
aednlaxer Feb 12, 2025
31c94c5
Remove commented code
aednlaxer Feb 12, 2025
1c2cdf7
Fix how bool is returned
aednlaxer Feb 12, 2025
db77f2c
Remove _platformMarkerTypeFromIndex
aednlaxer Feb 13, 2025
a8efceb
Update comment
aednlaxer Feb 13, 2025
0787c4c
Add mapId/cloudMapId assertion
aednlaxer Feb 13, 2025
1c61295
Add more unit tests for marker type and map ID
aednlaxer Feb 14, 2025
019e7e0
Reformat code
aednlaxer Feb 14, 2025
4655a38
Remove unused variable
aednlaxer Feb 14, 2025
93a7ad7
Simplify assertion
aednlaxer Feb 14, 2025
d65f9fa
Fix rebase issues
aednlaxer Apr 11, 2025
6c9fd7d
Fix markerType params
aednlaxer Apr 11, 2025
c30c172
Remove AdvancedMarkersCapabilityStatus from PlaceMarkerPage
aednlaxer Apr 14, 2025
afa509e
Fix comment style
aednlaxer Apr 14, 2025
09cf20b
Rename MarkerCollisionBehavior.required to requiredDisplay
aednlaxer Apr 14, 2025
1da95fe
Add completer to the test
aednlaxer Apr 14, 2025
74272fb
Add collision behavior example page
aednlaxer Apr 14, 2025
5ae4278
Restore pin config if-branch in FGMIconFromBitmap
aednlaxer Apr 14, 2025
4e603ea
Reformat code
aednlaxer Apr 14, 2025
d17d644
Add missing license block
aednlaxer Apr 14, 2025
95740a2
Fix enum name
aednlaxer Apr 14, 2025
3dc400a
Restore icon anchor
aednlaxer Apr 15, 2025
67200fa
Fix missing semicolon
aednlaxer Apr 15, 2025
c8f6b0c
Fix iOS tests
aednlaxer Apr 15, 2025
e55ce2a
Revert trailing comma
aednlaxer Apr 22, 2025
3f8622b
Change AdvancedMarker's zIndex type to int
aednlaxer Apr 23, 2025
1b77530
Merge branch 'main' into feature/google-maps-advanced-markers-support
aednlaxer Apr 29, 2025
dfb41b3
Merge branch 'main' into feature/google-maps-advanced-markers-support
aednlaxer May 15, 2025
1b37387
Fix duplicated test name
aednlaxer May 16, 2025
bc92715
Annotate collisionBehavior parameter (Java)
aednlaxer May 19, 2025
b0857e8
Remove duplicated line
aednlaxer May 19, 2025
439d97a
Fix collision behavior not being set correctly on iOS
aednlaxer May 20, 2025
517d3be
Convert innerHTML to String
aednlaxer May 21, 2025
351e375
Tweak marker to platform marker conversion
aednlaxer May 21, 2025
cc63ced
Merge branch 'main' into feature/google-maps-advanced-markers-support
aednlaxer May 21, 2025
f35b350
Ignore decimal point
aednlaxer May 21, 2025
28b0072
Merge branch 'feature/google-maps-advanced-markers-support' of github…
aednlaxer May 21, 2025
a91792c
Fix num to String conversion of an icon size
aednlaxer May 22, 2025
fc48a9b
Merge branch 'main' into feature/google-maps-advanced-markers-support
aednlaxer May 22, 2025
14e4778
Merge branch 'main' into feature/google-maps-advanced-markers-support
aednlaxer May 26, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions packages/google_maps_flutter/google_maps_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,24 @@ the `GoogleMap`'s `onMapCreated` callback.
The `GoogleMap` widget should be used within a widget with a bounded size. Using it
in an unbounded widget will cause the application to throw a Flutter exception.

### Advanced Markers

[Advanced Markers](https://developers.google.com/maps/documentation/javascript/advanced-markers/overview)
are map markers that offer extra customization options.
[Map ID](https://developers.google.com/maps/documentation/get-map-id) is
required in order to use Advanced Markers:

<?code-excerpt "readme_sample_advanced_markers.dart (AdvancedMarkersSample)"?>
```dart
body: GoogleMap(
// Set your Map ID.
mapId: 'my-map-id',
// Enable support for Advanced Markers.
markerType: GoogleMapMarkerType.advancedMarker,
initialCameraPosition: _kGooglePlex,
),
```

### Sample Usage

<?code-excerpt "readme_sample.dart (MapSample)"?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ void runTests() {
onMapCreated: (GoogleMapController controller) {
mapIdCompleter.complete(controller.mapId);
},
cloudMapId: kCloudMapId,
cloudMapId: kMapId,
),
);
await tester.pumpAndSettle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const CameraPosition kInitialCameraPosition =
CameraPosition(target: kInitialMapCenter, zoom: kInitialZoomLevel);

// Dummy map ID
const String kCloudMapId = '000000000000000'; // Dummy map ID.
const String kMapId = '000000000000000'; // Dummy map ID.

/// True if the test is running in an iOS device
final bool isIOS = defaultTargetPlatform == TargetPlatform.iOS;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';

import 'page.dart';
import 'place_advanced_marker.dart';

/// Page that demonstrates how to use custom [AdvanceMarker] icons.
class AdvancedMarkerIconsPage extends GoogleMapExampleAppPage {
/// Default constructor.
const AdvancedMarkerIconsPage({
Key? key,
required this.mapId,
}) : super(
key: key,
const Icon(Icons.image_outlined),
'Advanced marker icons',
);

/// Map ID to use for the GoogleMap.
final String? mapId;

@override
Widget build(BuildContext context) {
return _AdvancedMarkerIconsBody(mapId: mapId);
}
}

const LatLng _kMapCenter = LatLng(52.4478, -3.5402);

class _AdvancedMarkerIconsBody extends StatefulWidget {
const _AdvancedMarkerIconsBody({required this.mapId});

/// Map ID to use for the GoogleMap.
final String? mapId;

@override
State<_AdvancedMarkerIconsBody> createState() =>
_AdvancedMarkerIconsBodyState();
}

class _AdvancedMarkerIconsBodyState extends State<_AdvancedMarkerIconsBody> {
final Set<AdvancedMarker> _markers = <AdvancedMarker>{};

GoogleMapController? controller;

@override
Widget build(BuildContext context) {
return Column(
children: <Widget>[
AdvancedMarkersCapabilityStatus(controller: controller),
Expanded(
child: GoogleMap(
mapId: widget.mapId,
markerType: GoogleMapMarkerType.advancedMarker,
initialCameraPosition: const CameraPosition(
target: _kMapCenter,
zoom: 7.0,
),
markers: _markers,
onMapCreated: (GoogleMapController controller) {
setState(() {
this.controller = controller;
});
},
),
),
Padding(
padding: const EdgeInsets.all(16),
child: TextButton(
onPressed: _markers.isNotEmpty
? null
: () async {
final AssetMapBitmap asset = await BitmapDescriptor.asset(
const ImageConfiguration(
size: Size(12, 12),
),
'assets/red_square.png',
);
final AssetMapBitmap largeAsset =
await BitmapDescriptor.asset(
const ImageConfiguration(
size: Size(36, 36),
),
'assets/red_square.png',
);

setState(() {
_markers.addAll(<AdvancedMarker>[
// Default icon
AdvancedMarker(
markerId: const MarkerId('1'),
position: LatLng(
_kMapCenter.latitude + 1,
_kMapCenter.longitude + 1,
),
),
// Custom pin colors
AdvancedMarker(
markerId: const MarkerId('2'),
position: LatLng(
_kMapCenter.latitude - 1,
_kMapCenter.longitude - 1,
),
icon: BitmapDescriptor.pinConfig(
borderColor: Colors.red,
backgroundColor: Colors.black,
glyph: const CircleGlyph(color: Colors.red),
),
),
// Pin with text
AdvancedMarker(
markerId: const MarkerId('3'),
position: LatLng(
_kMapCenter.latitude - 1,
_kMapCenter.longitude + 1,
),
icon: BitmapDescriptor.pinConfig(
borderColor: Colors.blue,
backgroundColor: Colors.white,
glyph: const TextGlyph(
text: 'Hi!',
textColor: Colors.blue,
),
),
),
// Pin with bitmap
AdvancedMarker(
markerId: const MarkerId('4'),
position: LatLng(
_kMapCenter.latitude + 1,
_kMapCenter.longitude - 1,
),
icon: BitmapDescriptor.pinConfig(
borderColor: Colors.red,
backgroundColor: Colors.white,
glyph: BitmapGlyph(bitmap: asset),
),
),
// Custom marker icon
AdvancedMarker(
markerId: const MarkerId('5'),
position: LatLng(
_kMapCenter.latitude,
_kMapCenter.longitude,
),
icon: largeAsset,
),
]);
});
},
child: const Text('Add advanced markers'),
),
),
],
);
}
}
Loading