Refactor. Fires marker calibration
This commit is contained in:
parent
574c1afc33
commit
f970c6b4fe
9 changed files with 128 additions and 51 deletions
58
lib/zoomMapPlugin.dart
Normal file
58
lib/zoomMapPlugin.dart
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
import 'package:flutter/src/widgets/framework.dart';
|
||||
import 'package:flutter_map/plugin_api.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:comunes_flutter/comunes_flutter.dart';
|
||||
|
||||
class ZoomMapPluginOptions extends LayerOptions {
|
||||
final String text;
|
||||
|
||||
ZoomMapPluginOptions({this.text = ""});
|
||||
}
|
||||
|
||||
// https://github.com/apptreesoftware/flutter_map/blob/master/flutter_map_example/lib/pages/plugin_api.dart
|
||||
class ZoomMapPlugin extends MapPlugin {
|
||||
IconButton zoomButton(MapState mapState, IconData zoomIcon, int inc) {
|
||||
return new IconButton(
|
||||
icon: Icon(zoomIcon),
|
||||
onPressed: () {
|
||||
var currentZoom = mapState.zoom;
|
||||
var currentCenter = mapState.center;
|
||||
mapState.move(currentCenter, currentZoom + inc);
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget createLayer(LayerOptions options, MapState mapState) {
|
||||
if (options is ZoomMapPluginOptions) {
|
||||
/* print('point ${mapState
|
||||
.getPixelBounds(mapState.zoom)
|
||||
.bottomLeft}'); */
|
||||
return LayoutBuilder(
|
||||
builder: (context, constraints) =>
|
||||
Stack(fit: StackFit.expand, children: <Widget>[
|
||||
Positioned(
|
||||
top: constraints.maxHeight - 100,
|
||||
right: 10.0,
|
||||
// left: 10.0,
|
||||
child: new CenteredRow(
|
||||
children: <Widget>[
|
||||
new Column(
|
||||
children: <Widget>[
|
||||
zoomButton(mapState, Icons.zoom_in, 1),
|
||||
zoomButton(mapState, Icons.zoom_out, -1)
|
||||
],
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
]));
|
||||
}
|
||||
throw ("Unknown options type for ZoomMapPlugin"
|
||||
"plugin: $options");
|
||||
}
|
||||
|
||||
@override
|
||||
bool supportsLayer(LayerOptions options) {
|
||||
return options is ZoomMapPluginOptions;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue