Last active
April 16, 2019 11:32
-
-
Save shashank-p/bb3be90f29e19d4789125b9d2d2e61db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dependencies: | |
google_maps_flutter: ^0.5.7 | |
***************************************************************************************************************************************** | |
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
import 'package:google_maps_flutter/google_maps_flutter.dart'; | |
void main() => runApp(MyMap()); | |
class MyMap extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Google Maps Demo', | |
home: MapSample(), | |
); | |
} | |
} | |
class MapSample extends StatefulWidget { | |
@override | |
State<MapSample> createState() => MapSampleState(); | |
} | |
class MapSampleState extends State<MapSample> { | |
Completer<GoogleMapController> _controller = Completer(); | |
static final CameraPosition _kGooglePlex = CameraPosition( | |
target: LatLng(37.42796133580664, -122.085749655962), | |
zoom: 14.4746, | |
); | |
static final CameraPosition _kLake = CameraPosition( | |
bearing: 192.8334901395799, | |
target: LatLng(37.43296265331129, -122.08832357078792), | |
tilt: 59.440717697143555, | |
zoom: 19.151926040649414); | |
@override | |
Widget build(BuildContext context) { | |
return new Scaffold( | |
body: GoogleMap( | |
mapType: MapType.hybrid, | |
initialCameraPosition: _kGooglePlex, | |
onMapCreated: (GoogleMapController controller) { | |
_controller.complete(controller); | |
}, | |
), | |
floatingActionButton: FloatingActionButton.extended( | |
onPressed: _goToTheLake, | |
label: Text('To the lake!'), | |
icon: Icon(Icons.directions_boat), | |
), | |
); | |
} | |
Future<void> _goToTheLake() async { | |
final GoogleMapController controller = await _controller.future; | |
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Display Google Map with Given Lat and Lng with Zooming
: 16 April 2019