I am trying to display a random Flutter map using the flutter_maps package. When I was creating this, I couldn't find the 'layers' option under the map options. If I type layers I got an error "Parameter named 'layers' is not defined."
I have added all the required dependencies. How to solve this?
Code:
import 'package:flutter/material.dart';
import 'package:flutter_map/flutter_map.dart';
import 'package:latlong2/latlong.dart' as LatLng;
Container( //container 1
height: 800,
width: double.infinity,
child: FlutterMap(
options: MapOptions(
center: LatLng.LatLng(23.77176, 90.399452),
zoom: 8,
),
),
),
The layers
option is not available in the MapOptions
class of the flutter_map
package. Instead, you can add one or more layers to the map using the children
property of the FlutterMap
widget:
return FlutterMap(
options: MapOptions(
center: LatLng(51.509364, -0.128928),
zoom: 9.2,
),
nonRotatedChildren: [
AttributionWidget.defaultWidget(
source: 'OpenStreetMap contributors',
onSourceTapped: null,
),
],
children: [
TileLayer(
urlTemplate: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
userAgentPackageName: 'com.example.app',
),
],
);