info: fixed map coordinate update on image change
This commit is contained in:
parent
1976e10dee
commit
6cebd3e2ac
1 changed files with 14 additions and 6 deletions
|
@ -65,7 +65,15 @@ class ImageMap extends StatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
||||||
GoogleMapController controller;
|
GoogleMapController _controller;
|
||||||
|
|
||||||
|
@override
|
||||||
|
void didUpdateWidget(ImageMap oldWidget) {
|
||||||
|
super.didUpdateWidget(oldWidget);
|
||||||
|
if (widget.latLng != oldWidget.latLng && _controller != null) {
|
||||||
|
_controller.moveCamera(CameraUpdate.newLatLng(widget.latLng));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
@ -85,7 +93,7 @@ class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
||||||
target: widget.latLng,
|
target: widget.latLng,
|
||||||
zoom: widget.initialZoom,
|
zoom: widget.initialZoom,
|
||||||
),
|
),
|
||||||
onMapCreated: (controller) => setState(() => this.controller = controller),
|
onMapCreated: (controller) => setState(() => this._controller = controller),
|
||||||
rotateGesturesEnabled: false,
|
rotateGesturesEnabled: false,
|
||||||
scrollGesturesEnabled: false,
|
scrollGesturesEnabled: false,
|
||||||
zoomGesturesEnabled: false,
|
zoomGesturesEnabled: false,
|
||||||
|
@ -106,12 +114,12 @@ class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
||||||
Column(children: [
|
Column(children: [
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.add),
|
icon: Icon(Icons.add),
|
||||||
onPressed: controller == null ? null : () => zoomBy(1),
|
onPressed: _controller == null ? null : () => _zoomBy(1),
|
||||||
tooltip: 'Zoom in',
|
tooltip: 'Zoom in',
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
icon: Icon(Icons.remove),
|
icon: Icon(Icons.remove),
|
||||||
onPressed: controller == null ? null : () => zoomBy(-1),
|
onPressed: _controller == null ? null : () => _zoomBy(-1),
|
||||||
tooltip: 'Zoom out',
|
tooltip: 'Zoom out',
|
||||||
),
|
),
|
||||||
IconButton(
|
IconButton(
|
||||||
|
@ -124,9 +132,9 @@ class ImageMapState extends State<ImageMap> with AutomaticKeepAliveClientMixin {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
zoomBy(double amount) {
|
_zoomBy(double amount) {
|
||||||
settings.infoMapZoom += amount;
|
settings.infoMapZoom += amount;
|
||||||
controller.animateCamera(CameraUpdate.zoomBy(amount));
|
_controller.animateCamera(CameraUpdate.zoomBy(amount));
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Reference in a new issue