user_location_plugin
user_location_plugin copied to clipboard
User location marker not moving
I'm experiencing an issue with the user location marker where it does not update the user's current location, it only updates when the floating action button is pressed to center the map, i just followed what the example folder has adding a little changes to accomplish what i needed.
Here is the class for my map screen
class _mapState extends State<Map> {
MapController controller = MapController();
StreamController<LatLng> ubicacionStream = StreamController();
@override
Widget build(BuildContext context) {
ubicacionStream.stream.listen((onData) {});
UserLocationOptions userLocationOptions = UserLocationOptions(
context: context,
mapController: controller,
markers: markers,
locationUpdateInBackground: false,
locationUpdateIntervalMs: 500,
zoomToCurrentLocationOnLoad: true,
onLocationUpdate: (LatLng pos, double speed) =>
print("onLocationUpdate ${pos.toString()}"),
showHeading: true,
fabHeight: 75.0,
fabWidth: 75.0,
updateMapLocationOnPositionChange: false,
);
return Scaffold(
body: FlutterMap(
options: MapOptions(
center: LatLng(28.7174739, -106.1145165),
zoom: 13.0,
maxZoom: 17,
minZoom: 11,
interactiveFlags: InteractiveFlag.pinchZoom | InteractiveFlag.drag,
onLongPress: (lat) async {
var res = await location(lat);
return showDialog(context: context, builder: (context){
return VentanaAlerta(
titulo: "Ubicación seleccionada",
contenido: Text(
"Calle: ${res['Nombre']}\n"
"Colonia: ${res['Colonia']}\n"
"Codigo Postal: ${res['Codigo Postal']}\n"
"Localidad: ${res['Localidad']}"
),
ancho: 90.0,
alto: 150,
);
}
);
},
plugins: [
UserLocationPlugin()
],
),
layers: [
TileLayerOptions(
urlTemplate: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
subdomains: ['a', 'b', 'c'],
retinaMode: true && MediaQuery.of(context).devicePixelRatio > 1.0,
),
MarkerLayerOptions(markers: markers),
userLocationOptions
],
mapController: controller,
),
);
}
VentanaAlerta
is just a custom class that i created to show alert dialogs
Other thing to note is that the "Heading" figure is not shown on the map like this:
Does the problem about the "Heading" marker have something to do because I'm using OpenStreetmaps?
https://imgur.com/a/SytUYVL Seems that the image can not be seen, so here it is