Skip to content

Commit 5b5b505

Browse files
committed
Add advanced markers sample to readme_sample.dart
1 parent 1ddd27a commit 5b5b505

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

packages/google_maps_flutter/google_maps_flutter/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,14 +125,16 @@ in an unbounded widget will cause the application to throw a Flutter exception.
125125

126126
[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:
127127

128+
129+
<?code-excerpt "readme_sample.dart (AdvancedMarkersSample)"?>
128130
```dart
129131
GoogleMap(
130132
// Set your Map Id
131133
mapId: 'my-map-id',
132134
133135
// Let map know that you're using Advanced Markers
134136
markerType: MarkerType.advancedMarker,
135-
...
137+
initialCameraPosition: _kGooglePlex,
136138
),
137139
```
138140

packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'dart:async';
88

99
import 'package:flutter/material.dart';
1010
import 'package:google_maps_flutter/google_maps_flutter.dart';
11+
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
1112

1213
void main() => runApp(const MyApp());
1314

@@ -70,3 +71,28 @@ class MapSampleState extends State<MapSample> {
7071
}
7172
}
7273
// #enddocregion MapSample
74+
75+
// #docregion AdvancedMarkersSample
76+
class AdvancedMarkersSample extends StatelessWidget {
77+
const AdvancedMarkersSample({super.key});
78+
79+
static const CameraPosition _kGooglePlex = CameraPosition(
80+
target: LatLng(37.42796133580664, -122.085749655962),
81+
zoom: 14.4746,
82+
);
83+
84+
@override
85+
Widget build(BuildContext context) {
86+
return const Scaffold(
87+
body: GoogleMap(
88+
// Set your Map Id
89+
mapId: 'my-map-id',
90+
91+
// Let map know that you're using Advanced Markers
92+
markerType: MarkerType.advancedMarker,
93+
initialCameraPosition: _kGooglePlex,
94+
),
95+
);
96+
}
97+
}
98+
// #enddocregion AdvancedMarkersSample

0 commit comments

Comments
 (0)