Map fixes
This commit is contained in:
parent
f7d8bf9ae7
commit
3d27f20798
@ -11,19 +11,76 @@ class MapCard extends StatefulWidget {
|
|||||||
|
|
||||||
class _MapCardState extends State<MapCard> {
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
|
||||||
return CardWrapper(
|
return CardWrapper(
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.stretch,
|
crossAxisAlignment: CrossAxisAlignment.stretch,
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
CardHeader(name: widget.card.title),
|
CardHeader(name: widget.card.title),
|
||||||
EntitiesMap(
|
Stack(
|
||||||
aspectRatio: 1,
|
children: <Widget>[
|
||||||
entities: widget.card.entities,
|
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 List<EntityWrapper> entities;
|
||||||
final bool interactive;
|
final bool interactive;
|
||||||
final double aspectRatio;
|
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
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -34,12 +36,22 @@ class EntitiesMap extends StatelessWidget {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
Widget map = FlutterMap(
|
MapOptions mapOptions;
|
||||||
options: new MapOptions(
|
if (center != null) {
|
||||||
interactive: false,
|
mapOptions = MapOptions(
|
||||||
|
interactive: interactive,
|
||||||
|
center: center,
|
||||||
|
zoom: zoom ?? 10,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
mapOptions = MapOptions(
|
||||||
|
interactive: interactive,
|
||||||
bounds: LatLngBounds.fromPoints(points),
|
bounds: LatLngBounds.fromPoints(points),
|
||||||
boundsOptions: FitBoundsOptions(padding: EdgeInsets.all(40)),
|
boundsOptions: FitBoundsOptions(padding: EdgeInsets.all(40)),
|
||||||
),
|
);
|
||||||
|
}
|
||||||
|
Widget map = FlutterMap(
|
||||||
|
options: mapOptions,
|
||||||
layers: [
|
layers: [
|
||||||
new TileLayerOptions(
|
new TileLayerOptions(
|
||||||
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
urlTemplate: "https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",
|
||||||
@ -58,5 +70,4 @@ class EntitiesMap extends StatelessWidget {
|
|||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user