Map fixes
This commit is contained in:
parent
f7d8bf9ae7
commit
3d27f20798
@ -11,19 +11,76 @@ class MapCard extends StatefulWidget {
|
||||
|
||||
class _MapCardState extends State<MapCard> {
|
||||
|
||||
void _openMap(BuildContext context) {
|
||||
Navigator.of(context).push(MaterialPageRoute(
|
||||
builder: (bc) {
|
||||
return Scaffold(
|
||||
primary: false,
|
||||
/*appBar: new AppBar(
|
||||
backgroundColor: Colors.transparent,
|
||||
leading: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){
|
||||
Navigator.pop(context);
|
||||
}),
|
||||
actions: <Widget>[
|
||||
IconButton(
|
||||
icon: Icon(Icons.fullscreen),
|
||||
onPressed: () {},
|
||||
)
|
||||
],
|
||||
// Here we take the value from the MyHomePage object that was created by
|
||||
// the App.build method, and use it to set our appbar title.
|
||||
title: new Text("${widget.card.title ?? ""}"),
|
||||
),*/
|
||||
body: Container(
|
||||
color: Theme.of(context).primaryColor,
|
||||
child: SafeArea(
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
EntitiesMap(
|
||||
entities: widget.card.entities,
|
||||
interactive: true
|
||||
),
|
||||
Positioned(
|
||||
top: 0,
|
||||
left: 0,
|
||||
child: IconButton(icon: Icon(Icons.arrow_back), onPressed: (){
|
||||
Navigator.pop(context);
|
||||
})
|
||||
)
|
||||
],
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
|
||||
return CardWrapper(
|
||||
child: Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||
children: <Widget>[
|
||||
CardHeader(name: widget.card.title),
|
||||
EntitiesMap(
|
||||
aspectRatio: 1,
|
||||
entities: widget.card.entities,
|
||||
)
|
||||
Stack(
|
||||
children: <Widget>[
|
||||
GestureDetector(
|
||||
onTap: () => _openMap(context),
|
||||
child: EntitiesMap(
|
||||
aspectRatio: 1,
|
||||
interactive: false,
|
||||
entities: widget.card.entities,
|
||||
)
|
||||
),
|
||||
Positioned(
|
||||
bottom: 0,
|
||||
left: 0,
|
||||
child: Text('Tap to open interactive map', style: Theme.of(context).textTheme.caption)
|
||||
)
|
||||
],
|
||||
),
|
||||
],
|
||||
)
|
||||
);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user