小编And*_*evs的帖子

试图在MapView中模拟路线

我有一个CLLocation从文件中解析的对象数组.我想模拟用户沿着那条路线移动,我已经实现了这个:

for (CLLocation *loc in simulatedLocs) {
            [self moveUser:loc];
            sleep(1);
        }
Run Code Online (Sandbox Code Playgroud)

这是循环中调用的方法:

- (void)moveUser:(CLLocation*)newLoc
{
    CLLocationCoordinate2D coords;
    coords.latitude = newLoc.coordinate.latitude;
    coords.longitude = newLoc.coordinate.longitude;
    CustomAnnotation *annotation = [[CustomAnnotation alloc] initWithCoordinate:coords];
    annotation.title = @"User";

    // To remove the previous location icon
    NSArray *existingpoints = self.mapView.annotations;
    if ([existingpoints count] > 0) {
        for (CustomAnnotation *annotation in existingpoints) {
            if ([annotation.title isEqualToString:@"User"]) {
                [self.mapView removeAnnotation:annotation];
                break;
            }
        }
    }

    MKCoordinateRegion region = { coords, {0.1, 0.1} };
    [self.mapView setRegion:region animated:NO];
    [self.mapView addAnnotation: …
Run Code Online (Sandbox Code Playgroud)

iphone mapkit mkmapview ios ios5

5
推荐指数
1
解决办法
1099
查看次数

标签 统计

ios ×1

ios5 ×1

iphone ×1

mapkit ×1

mkmapview ×1