Display multiple points in map using flutter map

Viewed 386

Im a newbie in flutter. I'm making a project and I want to know how can I render the list of points using latlong plugin from flutter inside flutter map. I was able to render the first point but unable to show the other points in the list. Can you please guide me or correct my code.

Widget _mapBuilder(BuildContext context) {
  final List<LatLng> _mapPoints = [
    LatLng(9.7, 123.1),
    LatLng(10.7, 124.9),
    LatLng(11.7, 125.05)
];
 return FlutterMap(
 options: MapOptions(
  center: _mapPoints[1],
  zoom: 16.0,
 ),
 layers: [
   TileLayerOptions(
    urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
    subdomains: ['a', 'b', 'c'],
    attributionBuilder: (_) {
      return const Text("© OpenStreetMap contributors");
    },
  ),
  MarkerLayerOptions(markers: [
    for (var point in _mapPoints) ...[
      Marker(
        width: 15.0,
        height: 15.0,
        point: point,
        builder: (ctx) => Container(
          decoration: BoxDecoration(
              color: Colors.green,
              borderRadius: BorderRadius.circular(50.0),
              border: Border.all(color: Colors.white, width: 2)),
        ),
      ),
    ]
  ]),
],

);

0 Answers
Related