igaurab / user_location_plugin

A plugin for FlutterMap to show user location and handle location permissions.
MIT License
47 stars 75 forks source link

User location marker not moving #99

Open WaterBlueNewWorld opened 3 years ago

WaterBlueNewWorld commented 3 years ago

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: img

Does the problem about the "Heading" marker have something to do because I'm using OpenStreetmaps?

WaterBlueNewWorld commented 3 years ago

https://imgur.com/a/SytUYVL Seems that the image can not be seen, so here it is