diff --git a/components/navigation/navigationView/navigationViewController.ts b/components/navigation/navigationView/navigationViewController.ts index ce88d57..02d14cd 100644 --- a/components/navigation/navigationView/navigationViewController.ts +++ b/components/navigation/navigationView/navigationViewController.ts @@ -33,13 +33,13 @@ export const getNavigationViewController = ( return { setDestination: (waypoint: Waypoint, routingOptions?: RoutingOptions) => { let args: object[] = []; - args.push(waypoint); + args.push([waypoint]); if (routingOptions != null) { args.push(routingOptions); } - sendCommand(viewId, commands.setDestination, args); + sendCommand(viewId, commands.setDestinations, args); }, setDestinations: ( waypoints: Waypoint[], diff --git a/ios/react-native-navigation-sdk/NavViewController.m b/ios/react-native-navigation-sdk/NavViewController.m index 271a546..81365b0 100644 --- a/ios/react-native-navigation-sdk/NavViewController.m +++ b/ios/react-native-navigation-sdk/NavViewController.m @@ -201,25 +201,29 @@ - (void)setDestinations:(NSArray *)waypoints destinations = [[NSMutableArray alloc] init]; for (NSDictionary *wp in waypoints) { - NSString *placeId = @""; GMSNavigationMutableWaypoint *w; - placeId = wp[@"placeId"]; + NSString *placeId = wp[@"placeId"]; - if ([placeId isEqual:@""] && wp[@"position"] != nil) { + if (placeId && ![placeId isEqual:@""]) { + w = [[GMSNavigationMutableWaypoint alloc] initWithPlaceID:placeId title:wp[@"title"]]; + } else if (wp[@"position"]) { w = [[GMSNavigationMutableWaypoint alloc] - initWithLocation:[ObjectTranslationUtil getLocationCoordinateFrom:wp[@"position"]] - title:wp[@"title"] - preferSameSideOfRoad:wp[@"preferSameSideOfRoad"]]; - w.vehicleStopover = wp[@"vehicleStopover"]; + initWithLocation:[ObjectTranslationUtil getLocationCoordinateFrom:wp[@"position"]] + title:wp[@"title"]]; + } else { + // The validation will be done on the client, so just ignore this waypoint here. + continue; } - if (![placeId isEqual:@""]) { - w = [[GMSNavigationMutableWaypoint alloc] initWithPlaceID:placeId title:wp[@"title"]]; - w.vehicleStopover = wp[@"vehicleStopover"]; - w.preferSameSideOfRoad = wp[@"preferSameSideOfRoad"]; + if (wp[@"preferSameSideOfRoad"] != nil) { + w.preferSameSideOfRoad = [wp[@"preferSameSideOfRoad"] boolValue]; } + if (wp[@"vehicleStopover"] != nil) { + w.vehicleStopover = [wp[@"vehicleStopover"] boolValue]; + } + if (wp[@"preferredHeading"] != nil) { w.preferredHeading = [wp[@"preferredHeading"] intValue]; } diff --git a/ios/react-native-navigation-sdk/RCTNavViewManager.m b/ios/react-native-navigation-sdk/RCTNavViewManager.m index 6c0d1fd..4c18182 100644 --- a/ios/react-native-navigation-sdk/RCTNavViewManager.m +++ b/ios/react-native-navigation-sdk/RCTNavViewManager.m @@ -250,14 +250,6 @@ + (BOOL)requiresMainQueueSetup { }); } -RCT_EXPORT_METHOD(setDestination: (nonnull NSNumber *)reactTag - waypoints: (nonnull NSArray *)waypoints - routingOptions: (NSDictionary *)routingOptions) { - dispatch_async(dispatch_get_main_queue(), ^{ - [viewController setDestinations:waypoints withRoutingOptions: routingOptions]; - }); -} - RCT_EXPORT_METHOD(setDestinations: (nonnull NSNumber *)reactTag waypoints: (nonnull NSArray *)waypoints routingOptions: (NSDictionary *)routingOptions) {