Results 1 to 4 of 4

Thread: iOS: turn by turn navigation in combination with POITracking

  1. #1
    Etablierter skobbler
    Join Date
    21.10.2014
    Posts
    20

    iOS: turn by turn navigation in combination with POITracking

    Hi,

    for my pedestrian navigation app I need to generate a route along multiple POI. The route should be shown after the user reached the respective POI (Waypoint). The user shouldn't see the next route before he reaches the POI. 100 meters before every POI a sound file should be played and 20 meters before he reaches the POI the new route to the next POI should be generated and the turn by turn navigation should start navigating.
    Here the current route for the use case:
    http://bit.ly/1BqnSBd

    Here my code so far:
    PHP Code:
    NSLog(Poi1Played ? @"Yes" : @"No");
            if ([
    detectedPOI poiID] == && [detectedPOI distance] <= 100 && Poi1Played == 0) {
                [
    self->_audioPlayer stop];
                if (
    _audioPlayer.isPlaying) {
                    
    // player is playing
                    //NSLog(@"player is playing POI2");
                
    } else {
                    [
    self playSound:@"Usecase-02-Löwentor"];
                }
                
    Poi1Played 1;
                
    NSLog(@"POI 1 Löwentor in 70m");
            }
            if ([
    detectedPOI poiID] == && [detectedPOI distance] <= 20) {
                
    SKRouteSettingsroute = [[SKRouteSettings alloc]init];
                if (
    Simulation) {
                    
    NSLog(@"Simulation TRUE");
                    
    route.startCoordinate=CLLocationCoordinate2DMake(Poi1LatPoi1Long);
                } else {
                    
    NSLog(@"Simulation FALSE");
                    
    route.startCoordinate=CLLocationCoordinate2DMake(self.locationManager.location.coordinate.latitudeself.locationManager.location.coordinate.longitude);
                }
                
    route.destinationCoordinate=CLLocationCoordinate2DMake(Poi2LatPoi2Long);
                
    route.shouldBeRendered YES// If NO, the route will not be rendered.
                
    route.requestAdvices YES;
                
    route.numberOfRoutes 1;
                
    route.routeMode SKRoutePedestrian;
                
    route.requestExtendedRoutePointsInfo YES;
                [[
    SKRoutingService sharedInstancecalculateRoute:route];
                
                
    NSLog(@"POI 1 Löwentor in 20m");
            } 
    PHP Code:
    -(NSArray*)trackablePOIs
    {
        
    SKTrackablePOI *trackablePOI1 = [SKTrackablePOI trackablePOI];
        
    trackablePOI1.poiID 1;
        
    trackablePOI1.type kTrackablePOITypeIncident;
        
    trackablePOI1.coordinate CLLocationCoordinate2DMake(Poi1LatPoi1Long);
        
        
    SKTrackablePOI *trackablePOI2 = [SKTrackablePOI trackablePOI];
        
    trackablePOI2.poiID 2;
        
    trackablePOI2.type kTrackablePOITypeIncident;
        
    trackablePOI2.coordinate CLLocationCoordinate2DMake(Poi2LatPoi2Long);
        
        
    SKTrackablePOI *trackablePOI3 = [SKTrackablePOI trackablePOI];
        
    trackablePOI3.poiID 3;
        
    trackablePOI3.type kTrackablePOITypeIncident;
        
    trackablePOI3.coordinate CLLocationCoordinate2DMake(Poi3LatPoi3Long);
        
        
    SKTrackablePOI *trackablePOI4 = [SKTrackablePOI trackablePOI];
        
    trackablePOI4.poiID 4;
        
    trackablePOI4.type kTrackablePOITypeIncident;
        
    trackablePOI4.coordinate CLLocationCoordinate2DMake(Poi4LatPoi4Long);
        
        
    SKTrackablePOI *trackablePOI5 = [SKTrackablePOI trackablePOI];
        
    trackablePOI5.poiID 5;
        
    trackablePOI5.type kTrackablePOITypeIncident;
        
    trackablePOI5.coordinate CLLocationCoordinate2DMake(Poi5LatPoi5Long);
        return @[
    trackablePOI1,trackablePOI2,trackablePOI3,trackablePOI4,trackablePOI5];

    PHP Code:
    - (void)routingService:(SKRoutingService *)routingService didFinishRouteCalculationWithInfo:(SKRouteInformation*)routeInformation{
    NSLog(@"Route is calculated.");
        
        [
    routingService zoomToRouteWithInsets:UIEdgeInsetsZero]; // zooming to currrent route
        
        //TODO: make this setting global
        
    SKNavigationSettingsnavSettings = [SKNavigationSettings navigationSettings];
        
        if (
    Simulation) {
            
    navSettings.navigationType=SKNavigationTypeSimulation;
        } else {
            
    navSettings.navigationType=SKNavigationTypeReal;
        }
        
        
    navSettings.distanceFormat=SKDistanceFormatMetric;
        [
    SKRoutingService sharedInstance].mapView.settings.displayMode SKMapDisplayMode3D;
        [[
    SKRoutingService sharedInstance]startNavigationWithSettings:navSettings];
        
        
    //saveRoute to cache
    //    [[SKRoutingService sharedInstance]saveRouteToCache:routeInformation.routeID];
        
        
        
    NSArrayadvices = [[SKRoutingService sharedInstancerouteAdviceListWithDistanceFormat:SKDistanceFormatMetric];
        for (
    SKRouteAdvice *advice in advices)
        {
    //        NSLog(@"%@", advice.adviceInstruction);
        
    }
        
        
    NSArraycoords = [[SKRoutingService sharedInstancerouteCoordinatesForRouteWithId:routeInformation.routeID];
    //    NSLog(@"Route contains %lu elements",(unsigned long)coords.count);

            
    NSLog(@"New Route is calculated.");
        [
    self startPOITracking];

    My problem is that this doesn't work on real streets. In the Xcode Simulator everything works fine.
    After the first POI the sound file ist played, the new route is calculated and I see it on the map, but without any turn by turn navigation advices? After that moment only the sound files are played at the specific POI coordinates.

    Should I stop the navigation after every POI and clear the route? Should I clear the cache of the route?

    Thank you very much,
    Ivaylo

  2. #2
    Oberskobbler
    Join Date
    22.07.2014
    Posts
    399
    Hi Ivaylo,

    An issue regarding your question has been sent to our development team-we will get back with an answer as soon as we can

  3. #3
    Oberskobbler
    Join Date
    22.07.2014
    Posts
    399
    Direct from our developers:
    "When calculating a new route you have to set it as main in the SKRoutingService.mainRouteId. After that you need to start the navigation again so that it uses the newly calculated route."
    Let us know if everything is working as expected.

  4. #4
    Etablierter skobbler
    Join Date
    21.10.2014
    Posts
    20
    Perfect!!!
    Setting "[[SKRoutingService sharedInstance] setMainRouteId:routeInformation.routeID];" in my "didFinishRouteCalculationWithInfo" method solved the problem.

    Thank you very much,
    Ivaylo

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •