Skip to content
This repository was archived by the owner on Jul 11, 2021. It is now read-only.
This repository was archived by the owner on Jul 11, 2021. It is now read-only.

User location marker not moving #99

Description

@WaterBlueNewWorld

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions