Google Maps | Geo Search | unfinished

This commit is contained in:
2020-12-05 19:42:20 +01:00
parent f840ade2c8
commit 5f48de6027
12 changed files with 390 additions and 65 deletions

View File

@@ -0,0 +1,62 @@
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';
class RestaurantMapView extends StatefulWidget {
final List coordinates;
final String name;
final String type;
RestaurantMapView(
{@required this.coordinates, @required this.name, @required this.type});
@override
State<RestaurantMapView> createState() => RestaurantMapViewState();
}
class RestaurantMapViewState extends State<RestaurantMapView> {
Completer<GoogleMapController> _controller = Completer();
Map<MarkerId, Marker> markers = <MarkerId, Marker>{};
@override
Widget build(BuildContext context) {
final CameraPosition _initialPosition = CameraPosition(
target: LatLng(widget.coordinates[0], widget.coordinates[1]),
zoom: 17,
);
final MarkerId markerId = MarkerId("restaurant-marker");
final Marker marker = Marker(
markerId: markerId,
position: LatLng(widget.coordinates[0], widget.coordinates[1]),
infoWindow: InfoWindow(
title: '${widget.name}', snippet: 'Kuchnia: ${widget.type}'));
setState(() {
markers[MarkerId("restaurant-marker")] = marker;
});
return Scaffold(
body: GoogleMap(
mapType: MapType.normal,
initialCameraPosition: _initialPosition,
onMapCreated: (GoogleMapController controller) {
_controller.complete(controller);
},
markers: Set<Marker>.of(markers.values),
),
floatingActionButton: Padding(
padding: EdgeInsets.only(bottom: 20),
child: FloatingActionButton(
backgroundColor: Colors.grey[800],
onPressed: () {
Navigator.pop(context);
},
child: Icon(
Icons.arrow_back_outlined,
color: Colors.orange,
),
),
),
floatingActionButtonLocation: FloatingActionButtonLocation.startDocked,
);
}
}