import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; void main() { runApp(MaterialApp( home: new Scaffold( appBar: AppBar(title: const Text('Google Maps demo')), body: MapsDemo(), ), )); } class MapsDemo extends StatefulWidget { @override State createState() => MapsDemoState(); } class MapsDemoState extends State { GoogleMapController mapController; @override Widget build(BuildContext context) { return Padding( padding: EdgeInsets.all(15.0), child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Center( child: SizedBox( width: 300.0, height: 200.0, child: GoogleMap( options: GoogleMapOptions( mapType: MapType.hybrid, ), onMapCreated: _onMapCreated, ), ), ), RaisedButton( child: const Text('Go to London'), onPressed: mapController == null ? null : () { mapController.animateCamera(CameraUpdate.newCameraPosition( const CameraPosition( bearing: 270.0, target: LatLng(51.5160895, -0.1294527), tilt: 30.0, zoom: 17.0, ), )); mapController.addMarker(MarkerOptions( position: LatLng(51.5160895, -0.1294527), infoWindowText: InfoWindowText('London', 'Eine schöne Stadt') )); }, ), ], ), ); } void _onMapCreated(GoogleMapController controller) { setState(() { mapController = controller; }); } }