如何使用Skobbler开始跟踪POI

时间:2015-09-03 19:58:18

标签: ios objective-c skmaps

这是我创建可跟踪POI和启动POI跟踪的代码。

此代码放在我计算路线和开始导航之前

-(void)createTrackablePOIs
{

// Go through the route array and create POIs out of all added exits and locations
if ([Constants shared].routeArray.count>2){

    _trackablePOIs = [[NSMutableArray alloc] init];

    for (int i=1; i<[Constants shared].routeArray.count-1; i++) {
        if ([[Constants shared].routeArray[i] isKindOfClass:[Exit class]]){
            Exit *e = [Constants shared].routeArray[i];
            SKTrackablePOI* poi = [[SKTrackablePOI alloc] init];
            poi.poiID = e.idExit;
            poi.type = 1;
            poi.coordinate = CLLocationCoordinate2DMake(e.lat, e.lon);
            [self.trackablePOIs addObject:poi];

        }else{
            RoutePoint* rp = [Constants shared].routeArray[i];
            SKTrackablePOI *poi = [[SKTrackablePOI alloc] init];
            poi.poiID = rp.pointID;
            poi.type = 2;
            poi.coordinate = CLLocationCoordinate2DMake(rp.x,rp.y);
            [self.trackablePOIs addObject:poi];
        }
    }

    NSLog(@"%d POIs created and added to array",_trackablePOIs.count);

    self.poiTracker = [[SKPOITracker alloc] init];
    self.poiTracker.dataSource = self;
    self.poiTracker.delegate = self;

    // Create POI Tracking rules
    SKTrackablePOIRule *rule = [SKTrackablePOIRule trackablePOIRule];
    rule.routeDistance = 5000;
    rule.aerialDistance = 5000;
    [_poiTracker setRule:rule forPOIType:1];


    // Start POI tracking
    [_poiTracker startPOITrackerWithRadius:5000 refreshMargin:0.1 forPOITypes:@[@1,@2]];
}



}

-(NSArray*)poiTracker:(SKPOITracker *)poiTracker trackablePOIsAroundLocation:(CLLocationCoordinate2D)location inRadius:(int)radius withType:(int)poiType
{
return [self.trackablePOIs copy];
}

- (void)poiTracker:(SKPOITracker *)poiTracker didDectectPOIs:(NSArray *)detectedPOIs{
[detectedPOIs enumerateObjectsUsingBlock:^(SKDetectedPOI *detectedPOI,     NSUInteger index, BOOL *stop){
    NSLog(@"Detected: %@",[detectedPOI description]);
}];
NSLog(@"POI detected");
}

但是永远不会调用POI委托方法。无论我玩多少跟踪可跟踪的POI规则。

另外,另一个问题是,保证金在

中的确切含义
[_poiTracker startPOITrackerWithRadius:5000 refreshMargin:0.1 forPOITypes:@[@1,@2]];

0 个答案:

没有答案