@@ -201,25 +201,29 @@ - (void)setDestinations:(NSArray *)waypoints
201201 destinations = [[NSMutableArray alloc ] init ];
202202
203203 for (NSDictionary *wp in waypoints) {
204- NSString *placeId = @" " ;
205204 GMSNavigationMutableWaypoint *w;
206205
207- placeId = wp[@" placeId" ];
206+ NSString * placeId = wp[@" placeId" ];
208207
209- if ([placeId isEqual: @" " ] && wp[@" position" ] != nil ) {
208+ if (placeId && ![placeId isEqual: @" " ]) {
209+ w = [[GMSNavigationMutableWaypoint alloc ] initWithPlaceID: placeId title: wp[@" title" ]];
210+ } else if (wp[@" position" ]) {
210211 w = [[GMSNavigationMutableWaypoint alloc ]
211- initWithLocation: [ObjectTranslationUtil getLocationCoordinateFrom: wp[@" position" ]]
212- title: wp[@" title" ]
213- preferSameSideOfRoad: wp[@" preferSameSideOfRoad" ]];
214- w.vehicleStopover = wp[@" vehicleStopover" ];
212+ initWithLocation: [ObjectTranslationUtil getLocationCoordinateFrom: wp[@" position" ]]
213+ title: wp[@" title" ]];
214+ } else {
215+ // The validation will be done on the client, so just ignore this waypoint here.
216+ continue ;
215217 }
216218
217- if (![placeId isEqual: @" " ]) {
218- w = [[GMSNavigationMutableWaypoint alloc ] initWithPlaceID: placeId title: wp[@" title" ]];
219- w.vehicleStopover = wp[@" vehicleStopover" ];
220- w.preferSameSideOfRoad = wp[@" preferSameSideOfRoad" ];
219+ if (wp[@" preferSameSideOfRoad" ] != nil ) {
220+ w.preferSameSideOfRoad = [wp[@" preferSameSideOfRoad" ] boolValue ];
221221 }
222222
223+ if (wp[@" vehicleStopover" ] != nil ) {
224+ w.vehicleStopover = [wp[@" vehicleStopover" ] boolValue ];
225+ }
226+
223227 if (wp[@" preferredHeading" ] != nil ) {
224228 w.preferredHeading = [wp[@" preferredHeading" ] intValue ];
225229 }
0 commit comments