-
Notifications
You must be signed in to change notification settings - Fork 75
Current location marker does not change until map is moved #10
Comments
@boris612 true. I noticed that the marker will only change if the map is moving. If the map is not moving (either manually by setting |
@igaurab I had a look into this and in It seems to be an active issue in with recent one being fleaflet/flutter_map#458 where the author is proposing to use keys but It did not work for me Marker(point: LatLng(_currentLocation.latitude, _currentLocation.longitude),
builder: (context) {
return Stack(
key: UniqueKey(),
alignment: AlignmentDirectional.center,
children: <Widget>[
.....
],
);
}) maybe the reason being a maker is in the parent's widget tree. |
@igaurab It seems there are other active efforts to add user location However, they have added all the location consumtion and marker movment logic in the parent widget itself, rather than a plugin. The example flutter_map gives to move marker is to change values and call We are calling |
@igaurab Here's a neat implementation of making markers stateful It looks like he's subscribing to changes and then automatically call @override
void initState() {
mapController = MapController();
statefulMapController = StatefulMapController(mapController: mapController);
statefulMapController.onReady.then((_) => setState(() => ready = true));
sub = statefulMapController.changeFeed.listen((change) => setState(() {}));
super.initState();
} Also, https://github.com/synw/livemap/ which shows the users live locations, has been built on top of it. |
Hi guys. I wrote these packages. It's good to see guys that care about the question of rendering positions on a map. I've been working on that since a while. The question here is map assets state management. I have some ideas about that and I hope you don't mind if I sneak into your discussion to share some points of view. The stateful map controller is able to manage all assets on map. The rendering of the map state is independant of it. As exposed below the suggested solution now is to use a stream of changes to trigger I am actually thinking about rewriting the livemap package around a new state management paradigm using Provider, even thinking of dropping it in favor of another package that automatically manage all the map state (currently under heavy development): Fluxmap. I needed to update location of multiple devices on the map and needed a solution for managing frequent state updates. The paradigm is: provide a stream of location updates to the map, the rest is managed. Internaly it uses a stream provider to rebuild on state change: ex. code. The map state is accessible to the user. So basically the user just has to declare an instance of the map state, and start using the map controller or provide positions updates: all the rebuilds will be managed. These are handled via an rxdart stream internaly to debounce updates, so it can handle high toughtput of map updates. About the stateful map controller if you want to use it be sure that it will be maintained: I use it in a lot of packages and apps. About the livemap package if I could drop it in favor of your package and help you here it would be fine. If you use the map controller feel free to share your thoughts about it and open issues with your remarks, feedback is welcome. |
Hi. I am currently porting my map_controller to a plugin to avoid having to listen to a stream for updates and faced the same problem. I found a way: in if (!widget.options.updateMapLocationOnPositionChange) {
widget.map.fitBounds(widget.map.bounds, FitBoundsOptions());
} [Edit] : this is a workaround, it does not work very well if the actions are repeated. I opened an issue in the flutter_map repo to find a viable solution |
An another (dirty) workaround could be to slightly move map and return back to the same position. For example if updateMapLocationOnPositionChange is set to false then this code could help: var zoom = widget.options.mapController.zoom;
widget.options.mapController.move(widget.options.mapController.center,
widget.options.mapController.zoom + 0.000001);
widget.options.mapController.move(widget.options.mapController.center, zoom); |
@boris612 I made those exact changes and sent a PR
@boris612 I made those exact changes and sent a PR. I am ok with this workaround until flutter_map provides a better alternative |
Co-authored-by: igaurab <[email protected]>
When
updateMapLocationOnPositionChange
option is set tofalse
, current location marker does not change to a new location (although it prints new location in console) until the map is moved.The text was updated successfully, but these errors were encountered: