Is there any ETA of the current location function?
For what it's worth, I've been using https://pub.dartlang.org/packages/location with it
For what it's worth, I've been using https://pub.dartlang.org/packages/location with it
I know that that is available also there are GeoLocation packages but I want to use as little packages as possible
I've been trying to use that same package, but I can't seem to get it to draw a marker at the current location. @ibrierley do you have an example showing a dynamic marker?
@BOBODDY I've also used the location and geolocator package. With both packages it was possible to draw the current location on a map. I recommend to use the BLoC pattern to provide a stream for the current position then it is easy to use it on a flutter_map widget:
@override
Widget build(BuildContext context) {
final locationProviderBloc = LocationProviderBloc.of(context);
return StreamBuilder<LatLng>(
stream: locationProviderBloc.outLocationUpdate,
builder: (BuildContext context, AsyncSnapshot<LatLng> snapshot) {
final yourLocationLayer = MarkerLayerOptions(
markers: snapshot.data != null
? <Marker>[buildYourLocationMarker(snapshot.data)]
: <Marker>[],
);
return FlutterMap(
mapController: widget.controller.mapController,
options: widget.mapOptions,
layers: [yourLocationLayer],
);
},
);
}
I've also tested to draw the device heading on the your location marker. To do that the marker itself has also a stream builder which provides the heading value and when the value changed the marker will be rebuilt.
@BOBODDY Raimunds example looks good. If you are still stuck, maybe let us know the specific problem with the relevant bit of code and any errors maybe there will be some ideas. Try printing out the coordinates in the build method, to make sure the state is getting updated correctly.
If you are using multiple layers, make sure the ordering is correct, so the marker comes last.
Thank you both. This is my first flutter app so I didn't know about streams and StreamBuilder. I think it's working now.
glad it's working!
Most helpful comment
@BOBODDY I've also used the location and geolocator package. With both packages it was possible to draw the current location on a map. I recommend to use the BLoC pattern to provide a stream for the current position then it is easy to use it on a flutter_map widget:
I've also tested to draw the device heading on the your location marker. To do that the marker itself has also a stream builder which provides the heading value and when the value changed the marker will be rebuilt.