0

I am working on a navigation app that will give turn by turn navigation. I am using google directions API to plot best route between points. Apart from source and destination user can add up to 8 waypoints. I have stored all the coordinates in an array and in didUpdateLocations method i am checking the distance between current location and coordinates stored in array. If the distance is less than 5 meters then the user is going in the right direction

- (void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
CLLocation *myLocation = [locations lastObject];

BOOL goingWrongWay = YES;
//Searching Current Location in Coordinates Array
for(int i=0;i<self.decodedArray.count;i++)
{
    CLLocation *tempLoc = [self.decodedArray objectAtIndex:i];

    //NSLog(@"distance=%f", [myLocation distanceFromLocation:tempLoc]);
    if([myLocation distanceFromLocation:tempLoc]<=5)
    {

            goingWrongWay = NO;
            break;

    }
}
if(goingWrongWay)
    self.title = @"Wrong Way";
else
    self.title = @"On Track";

NSLog(@"YES");
if(isShowingRoute)
{
    NSLog(@"YES");
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:myLocation.coordinate.latitude
                                                            longitude:myLocation.coordinate.longitude
                                                                 zoom:19.0];
    [mapView animateToCameraPosition:camera];
}
}

Is there any other way to detect whether the user is going in the right direction or not as i have to Re-route user. BTW i am using google maps SDK for ios

Virat Naithani
  • 783
  • 12
  • 31
  • 1
    Using the Directions API and Google Maps for turn by turn navigation is against the Google Maps Terms of Service (https://developers.google.com/maps/terms). Section 10.2.c.ii: No Navigation, Autonomous Vehicle Control, or Enterprise Applications. – skarE Aug 01 '13 at 01:02
  • In that case i will mapquest api or any other api, but problem is still the same – Virat Naithani Aug 01 '13 at 06:02
  • +1 for pointing the clause out. So is there any alternative service with Google API itself which is legal also? – geekay Jun 24 '15 at 11:03

0 Answers0