handleMethodCall method

Future handleMethodCall(
  1. int idOSM
)

Handles method calls over the MethodChannel of this plugin. Note: Check the "federated" architecture for a new way of doing this: https://flutter.dev/go/federated-plugins

Implementation

Future<dynamic> handleMethodCall(int idOSM) async {
  _channels[idOSM]!.setMethodCallHandler((call) async {
    switch (call.method) {
      case "initMap":
        final result = call.arguments as bool;
        _streamController.add(MapInitialization(idOSM, result));
        break;
      case "onSingleTapListener":
        final result = call.arguments as String;
        _streamController
            .add(SingleTapEvent(idOSM, GeoPoint.fromString(result)));
        break;
      case "receiveGeoPoint":
        final result = call.arguments as String;
        _streamController
            .add(GeoPointEvent(idOSM, GeoPoint.fromString(result)));
        break;
      case "receiveRegionIsChanging":
        final result = call.arguments;
        _streamController
            .add(RegionIsChangingEvent(idOSM, Region.fromMap(result)));
        break;
      case "receiveRoad":
        final roadKey = call.arguments as String;
        if (map != null && map!.roadsWebCache.containsKey(roadKey)) {
          _streamController
              .add(RoadTapEvent(idOSM, map!.roadsWebCache[roadKey]!));
        }
        break;
      case "receiveUserLocation":
        final result = call.arguments;
        final geoPt = GeoPoint.fromString(result);
        _streamController.add(
          UserLocationEvent(
            idOSM,
            UserLocation(
              latitude: geoPt.latitude,
              longitude: geoPt.latitude,
            ),
          ),
        );
        break;
      default:
        throw PlatformException(
          code: 'Unimplemented',
          details:
              'osm_web_plugin for web doesn\'t implement \'${call.method}\'',
        );
    }
  });
}