mapbox-maps-flutter icon indicating copy to clipboard operation
mapbox-maps-flutter copied to clipboard

Is there a way to move location puck to other lat/lng

Open basvdijk opened this issue 1 year ago • 0 comments

I was wondering if there is a way to move the location puck. I am having a line on the map. When the position is near this line I would like to snap it to the line.

This snippet fetches the location of the puck, but I could not find a way to change the location.

    try {
      if (Platform.isAndroid) {
        layer =
            await mapboxMap?.style.getLayer('mapbox-location-indicator-layer');
      } else {
        layer = await mapboxMap?.style.getLayer('puck');
      }
    } catch (e) {
      developer.log(e.toString());
    }

    if (layer == null) return;

    var location = (layer as LocationIndicatorLayer).location;

Currently I solve this issue to use a pointAnnotationManager to add an annotation to act as the location puck and move it around. However the "real" puck looks a lot better and it would save a lot of calculation.

basvdijk avatar May 08 '24 14:05 basvdijk