handleTouchEvent method
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 index of the touch event (multi-touch index).touchType: The type of the touch event:0= down1= move2= up3= 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
- GemError.success if the event was accepted for processing.
- GemError.activation if the map view is not initialized or invalid.
- GemError.inUse if another operation prevents handling the event.
- GemError.noMemory if memory allocation failed while queuing the event.
- GemError.notFound if required internal objects are missing.
- Other GemError codes for additional error conditions.
Implementation
GemError handleTouchEvent(
final int pointerIndex,
final int touchType,
final int x,
final int y,
) {
if (GemKitPlatform.instance.androidVersion > -1) {
unawaited(
GemKitPlatform.instance
.getChannel(mapId: mapId)
.invokeMethod(
'handleTouchEvent',
jsonEncode(<String, int>{
'x': x,
'y': y,
'touchType': touchType,
'pointerIndex': pointerIndex,
}),
),
);
return GemError.success;
}
unawaited(
GemKitPlatform.instance
.getChannel(mapId: mapId)
.invokeMethod<String>(
'callObjectMethod',
jsonEncode(<String, dynamic>{
'id': _pointerId,
'class': 'MapView',
'method': 'handleTouchEvent',
'args': <String, dynamic>{
'x': x,
'y': y,
'touchType': touchType,
'pointerIndex': pointerIndex,
},
}),
),
);
return GemError.success;
// final OperationResult resultString = objectMethod(
// _pointerId,
// 'MapView',
// 'handleTouchEvent',
// );
// return GemErrorExtension.fromCode(resultString['gemApiError']);
}