import
'dart:async'
;
import
'dart:collection'
;
import
'package:flutter/material.dart'
;
import
'package:google_maps_flutter/google_maps_flutter.dart'
;
class
HomePage extends StatefulWidget {
const
HomePage({Key? key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class
_HomePageState extends State<HomePage> {
Completer<GoogleMapController> _controller = Completer();
static
final CameraPosition _kGoogle =
const
CameraPosition(
target: LatLng(19.0759837, 72.8776559),
zoom: 14,
);
final Set<Marker> _markers = {};
final Set<Polyline> _polyline = {};
List<LatLng> latLen = [
LatLng(19.0759837, 72.8776559),
LatLng(28.679079, 77.069710),
LatLng(26.850000, 80.949997),
LatLng(24.879999, 74.629997),
LatLng(16.166700, 74.833298),
LatLng(12.971599, 77.594563),
];
@override
void
initState() {
super.initState();
for
(
int
i=0; i<latLen.length; i++){
_markers.add(
Marker(
markerId: MarkerId(i.toString()),
position: latLen[i],
infoWindow: InfoWindow(
title:
'HOTEL'
,
snippet:
'5 Star Hotel'
,
),
icon: BitmapDescriptor.defaultMarker,
)
);
setState(() {
});
_polyline.add(
Polyline(
polylineId: PolylineId(
'1'
),
points: latLen,
color: Colors.green,
)
);
}
}
@override
Widget build(BuildContext context) {
return
Scaffold(
appBar: AppBar(
backgroundColor: Color(0xFF0F9D58),
title: Text(
"GFG"
),
),
body: Container(
child: SafeArea(
child: GoogleMap(
initialCameraPosition: _kGoogle,
mapType: MapType.normal,
markers: _markers,
myLocationEnabled:
true
,
myLocationButtonEnabled:
true
,
compassEnabled:
true
,
polylines: _polyline,
onMapCreated: (GoogleMapController controller){
_controller.complete(controller);
},
),
),
),
);
}
}