Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
import 'src/locations.dart' as locations;
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
_MyAppState createState() => _MyAppState();
class _MyAppState extends State<MyApp> {
final Map<String, Marker> _markers = {};
Future<void> _onMapCreated(GoogleMapController controller) async {
final googleOffices = await locations.getGoogleOffices();
setState(() {
for (final office in googleOffices.offices) {
final marker = Marker(
markerId: MarkerId(,
position: LatLng(, office.lng),
infoWindow: InfoWindow(
snippet: office.address,
_markers[] = marker;
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Google Office Locations'),
backgroundColor: Colors.white,
body: GoogleMap(
onMapCreated: _onMapCreated,
initialCameraPosition: CameraPosition(
target: const LatLng(20.5937, 78.9629),
zoom: 4,
markers: _markers.values.toSet(),
mapType: MapType.normal,
tiltGesturesEnabled: true,
compassEnabled: true,
rotateGesturesEnabled: true,
myLocationEnabled: true,
theme: ThemeData(
fontFamily: 'Raleway',
textTheme: Theme.of(context).textTheme.apply(
displayColor: Colors.grey[600],
// This colors the [InputOutlineBorder] when it is selected
primaryColor: Colors.grey[500],
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment