Map fixes

This commit is contained in:
estevez-dev
2020-07-22 13:32:34 +03:00
parent f7d8bf9ae7
commit 3d27f20798
2 changed files with 79 additions and 11 deletions

View File

@ -6,8 +6,10 @@ class EntitiesMap extends StatelessWidget {
final List<EntityWrapper> entities;
final bool interactive;
final double aspectRatio;
final LatLng center;
final double zoom;
const EntitiesMap({Key key, this.entities: const [], this.aspectRatio, this.interactive: false}) : super(key: key);
const EntitiesMap({Key key, this.entities: const [], this.aspectRatio, this.interactive: true, this.center, this.zoom}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -34,12 +36,22 @@ class EntitiesMap extends StatelessWidget {
);
}
});
Widget map = FlutterMap(
options: new MapOptions(
interactive: false,
MapOptions mapOptions;
if (center != null) {
mapOptions = MapOptions(
interactive: interactive,
center: center,
zoom: zoom ?? 10,
);
} else {
mapOptions = MapOptions(
interactive: interactive,
bounds: LatLngBounds.fromPoints(points),
boundsOptions: FitBoundsOptions(padding: EdgeInsets.all(40)),
),
);
}
Widget map = FlutterMap(
options: mapOptions,
layers: [
new TileLayerOptions(
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
@ -58,5 +70,4 @@ class EntitiesMap extends StatelessWidget {
}
return map;
}
}