Skip to content

The longPress event is fired only after the finger is released #1118

@astheras

Description

@astheras

Here’s what I want to achieve: I want to create a map object (using PointAnnotationManager) on a long tap. However, the action doesn't trigger until I release my finger, which isn't very intuitive for the user. The PointAnnotationManager behaves the same way. I would like to implement a long press that, once triggered, allows the user to immediately drag the object across the map. Is there an option to make the long press behave in a more traditional way?

MapWidget(
          key: const Key('AppMap--MapWidget'),

          styleUri:
              controller.repository.localStorage.load<String>(
                'map_type',
              ) ??
              MapboxStyles.OUTDOORS,
          cameraOptions: controller.initialCameraOptions,
          onMapCreated: controller.onMapCreated,
          onCameraChangeListener: controller.onCameraChangeListener,
          onLongTapListener: controller.onLongTapListener,
          onTapListener: controller.onTapListener,
          onStyleLoadedListener: controller.onStyleLoadedListener,
        ),
 Future<void> initAnnotations({
    required PointAnnotationManager pointManagerIcon,
    required PointAnnotationManager pointManagerLabel,
  }) async {
    await pointManagerIcon.setIconRotationAlignment(
      IconRotationAlignment.MAP,
    );
    await pointManagerLabel.setIconRotationAlignment(
      IconRotationAlignment.VIEWPORT,
    );

    _pointManagerIcon = pointManagerIcon;
    _pointManagerLabel = pointManagerLabel;

    _pointManagerLabel.tapEvents(
      onTap: _onTapMapLabel,
    );

    _pointManagerIcon.dragEvents(
      onEnd: _onDragEnd,
    );

    _pointManagerIcon.longPressEvents(
      onLongPress: _onLongPress,
    );
  }
  Future<PointAnnotation> _createIconPointAnnotation({
    required LatLng location,
    required Uint8List image,
    required String imageId,
    required LocatedObjectModel locatedObject,
  }) async {
    final annotation = PointAnnotationOptions(
      customData: {
        "image_id": imageId,
      },
      geometry: Point(
        coordinates: Position(location.longitude, location.latitude),
      ),

      image: image,
      iconRotate: _iconRotateFromAzimuth(locatedObject.directionAzimuthDegree),
      //isDraggable: user.isAdmin || user.isOperator,
    );
    return _pointManagerIcon.create(annotation);
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions