handleTouchEvent method

GemError handleTouchEvent(
  1. int pointerIndex,
  2. int touchType,
  3. int x,
  4. int y,
)

Handle a touch event delivered to the map view.

Sends a single pointer touch event (down/move/up/cancel) to the map view for processing. The call is non-blocking; the event is dispatched for handling and this method returns immediately. Use this to forward raw pointer events received by the embedding application so the map can respond to user interaction.

The API user usually does not need to call this method directly, as the GemMapController automatically forwards touch events.

Parameters

  • pointerIndex: The pointer identifier reported by the platform (PointerEvent.device). It is mapped internally to a small multi-touch index that stays stable between the pointer's down and up events.
  • touchType: The type of the touch event:
    • 0 = down
    • 1 = move
    • 2 = up
    • 3 = cancel
  • x: The x coordinate of the touch event in physical pixels, relative to the map view's top-left corner.
  • y: The y coordinate of the touch event in physical pixels, relative to the map view's top-left corner.

Returns

Implementation

GemError handleTouchEvent(int pointerIndex, int touchType, int x, int y) {
  _touchSample[_touchSampleX] = x;
  _touchSample[_touchSampleY] = y;
  _touchSample[_touchSampleType] = touchType;
  _touchSample[_touchSamplePointerIndex] = _acquirePointerSlot(pointerIndex);

  // Reusing one buffer is safe: invokeMethod encodes the message
  // synchronously. ignore() rather than unawaited() so a rejected sample
  // cannot surface as an unhandled async error on this per-sample path.
  GemKitPlatform.instance
      .getChannel(mapId: mapId)
      .invokeMethod<void>('handleTouchEvent', _touchSample)
      .ignore();

  if (touchType == _touchTypeUp || touchType == _touchTypeCancel) {
    _pointerSlots.remove(pointerIndex);
  }
  return GemError.success;
}