66 lines
1.9 KiB
Dart
66 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'dart:async';
|
|
import 'package:google_maps_flutter/google_maps_flutter.dart';
|
|
|
|
|
|
class Map extends StatefulWidget {
|
|
@override
|
|
State<Map> createState() => MapState();
|
|
}
|
|
|
|
class MapState extends State<Map> {
|
|
Completer<GoogleMapController> _controller = Completer();
|
|
|
|
static const CameraPosition _kGooglePlex = CameraPosition(
|
|
target: LatLng(55.427320, 13.819257),
|
|
zoom: 14.4746,
|
|
);
|
|
|
|
static const Marker _kGooglePlexMarker = Marker(
|
|
markerId:MarkerId('_kGooglePlex'),
|
|
infoWindow: InfoWindow(title: 'Gustavsberg'),
|
|
icon: BitmapDescriptor.defaultMarker,
|
|
position: LatLng(59.322092, 18.388238),
|
|
);
|
|
static const CameraPosition _kLake = CameraPosition(
|
|
// bearing: 192.8334901395799,
|
|
target: LatLng(59.40675254370429, 17.94530832905887),
|
|
// tilt: 59.440717697143555,
|
|
zoom: 19.151926040649414);
|
|
|
|
static const Marker _kKistaMarker = Marker(
|
|
markerId:MarkerId('_kGooglePlex'),
|
|
infoWindow: InfoWindow(title: 'DSV Kista'),
|
|
icon: BitmapDescriptor.defaultMarker,
|
|
position: LatLng(59.40675254370429, 17.94530832905887),
|
|
);
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Scaffold(
|
|
body: GoogleMap(
|
|
mapType: MapType.normal,
|
|
/* markers: {
|
|
_kGooglePlexMarker,
|
|
_kKistaMarker,
|
|
},*/
|
|
initialCameraPosition: _kGooglePlex,
|
|
onMapCreated: (GoogleMapController controller) {
|
|
_controller.complete(controller);
|
|
},
|
|
),
|
|
floatingActionButton: FloatingActionButton.extended(
|
|
onPressed: _goToTheLake,
|
|
label: const Text('To Kista!'),
|
|
icon: const Icon(Icons.directions_boat),
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _goToTheLake() async {
|
|
final GoogleMapController controller = await _controller.future;
|
|
controller.animateCamera(CameraUpdate.newCameraPosition(_kLake));
|
|
}
|
|
}
|
|
|