-
-
Notifications
You must be signed in to change notification settings - Fork 860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update map center #10
Comments
Good catch! Yes this is definitely something we want to support. I am thinking the best API for this is to optionally include a "controller" (similar to a TextField's TextEditingController) that allows users to programmatically change things that are stateful, like the current zoom level and position. This is opposed to things stateless things like markers, which can be updated with a setState() on the parent widget. |
I've forked the plugin and exposed the ...
class _LocationPickerDialogState extends State<_LocationPickerDialog> {
MapState _mapState;
Location _location;
double _zoom;
Location get center {
LatLng center = _mapState.center;
if (center == null) return null;
return new Location(
latitude: center.latitude,
longitude: center.longitude,
);
}
@override
void initState() {
super.initState();
final location = widget.initialLocation ?? Location.zero;
_mapState = new MapState(new MapOptions(
center: location.latLng,
zoom: _zoom,
));
_mapState.onMoved.listen((_) {
final location = center;
if (location != null) {
setState(() {
_location = center;
});
}
});
}
Widget _buildPicker() {
return new FlutterMap(
mapState: _mapState,
layers: [
new TileLayerOptions(
urlTemplate: widget.urlTemplate,
additionalOptions: widget.additionalOptions,
),
_getMarkerLayerOptions(),
],
);
}
... This way I can query all the Awesome widget guys. |
pull requests welcome! |
closed by #25 - thanks for the help! |
please add a example or documentation!!! |
@gimox can you file a separate issue for documentation? thanks! |
Ok |
Hi ! |
try this:
|
@gimox |
@gimox mapController is always null for me. |
@OllyDixon Btw I have been scratching my head for like 4 hours to change map's center by calling setState and just before giving up I found this. Thank you so much @avioli |
Thankyou It worked for me |
@johnpryan thanks for your great effort. I am facing a problem to save this map after adding pin/marker. Can you help me to save this map with new marker latitude and longitude? |
thank you very much!!! |
hello @OllyDixon how did you manage to reload center and zoom on flutter map i'm stuck on it since 3days !! |
Also, thanks for the help from this thread! |
It's work fine for me. Thanks! |
Hi there,
first of all, thank you for such a great widget that enabled our transition to Flutter. I have a question/feature request: I've integrated user's position into the map as a marker (which seems to work fine). However, I'd like to have have a button for moving the map's center to the the current user's location. But simply setting map's center won't work. So I'm interested in any suggestions about the options I have (might include modifying flutter_map code).
Thank you for your support,
Ziga Patacko Koderman
The text was updated successfully, but these errors were encountered: