handleMessage method

  1. @override
void handleMessage(
  1. MapViewController mapViewController,
  2. Map<String, dynamic> payload
)
override

Implementation

@override
void handleMessage(
  MapViewController mapViewController,
  Map<String, dynamic> payload,
) async {
  mapViewController._usingViewerNavigation = false;
  var sdk = SitumSdk();
  // Calculate route and start navigation. WayfindingController will listen
  // for native callbacks to get up to date with the navigation status, using
  // the internal _methodCallHandler.
  var directionsMessage = createDirectionsMessage(payload);
  var directionsRequest = createDirectionsRequest(payload);
  mapViewController._interceptDirectionsRequest(directionsRequest);
  var navigationRequest =
      createNavigationRequest(payload["navigationRequest"]);
  mapViewController._interceptNavigationRequest(navigationRequest);
  try {
    SitumRoute situmRoute = await sdk.requestNavigation(
      directionsRequest,
      navigationRequest,
    );
    mapViewController._setNavigationRoute(
      directionsMessage.originIdentifier,
      directionsMessage.destinationIdentifier,
      situmRoute,
    );
  } on PlatformException catch (e) {
    mapViewController._setRouteError(e.code);
  } catch (e) {
    mapViewController._setRouteError(-1);
  }
}