Skip to content

Commit 588c689

Browse files
committed
Add advanced markers sample to readme_sample.dart
1 parent ff474bd commit 588c689

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
@@ -120,14 +120,16 @@ in an unbounded widget will cause the application to throw a Flutter exception.
120120

121121
[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:
122122

123+
124+
<?code-excerpt "readme_sample.dart (AdvancedMarkersSample)"?>
123125
```dart
124126
GoogleMap(
125127
// Set your Map Id
126128
mapId: 'my-map-id',
127129
128130
// Let map know that you're using Advanced Markers
129131
markerType: MarkerType.advancedMarker,
130-
...
132+
initialCameraPosition: _kGooglePlex,
131133
),
132134
```
133135

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)