0

したがって、ここで行う必要があるのは、デフォルトのブルーマーブルドロップを使用して、マップ上に2人のユーザーの場所を表示する必要があるということです。

タスクは、ユーザーAが現在の位置座標を5〜10秒ごとにWebサーバーにアップロードし続け、そこからユーザーBが5〜10秒ごとにその位置をプルすることです。したがって、MKMapViewでは、ユーザーBにはデフォルトの位置アノテーションを使用して自分の現在の位置が表示されますが、ユーザーBのmapViewにユーザーAの位置をアノテーションを付けて表示する必要もあります。

場所は5〜10秒ごとに更新されるため、ピン注釈を使用できなくなりました。2番目のユーザーの位置が静的ではなく移動中であることをユーザーが取得できるように、2番目のユーザーのプル位置にデフォルトのユーザー注釈(青いマーブルドロップ)を表示する必要があります。ピン注釈は、場所が静的であることを示唆しています。

どうすればそれを達成できますか?

4

1 に答える 1

1
-(void)updateLocation
{// this will update your location
    NSString *latitude = @"0.0";
    NSString *longitude=@"0.0";
    MyAnnotation *ann = [[MyAnnotation alloc] initWithLatitude:latitude Longitude:longitude];
    [self.theMapView removeAnnotations:[self.theMapView annotations]];
    [self.theMapView performSelectorOnMainThread:@selector(addAnnotation:) withObject:ann waitUntilDone:YES];

    MKCoordinateRegion region = MKCoordinateRegionMake(CLLocationCoordinate2DMake(0.0, 0.0), MKCoordinateSpanMake(0.1f, 0.1f));
    [self.theMapView setRegion:region];

}

- (MKAnnotationView *) mapView:(MKMapView *)mapView1 viewForAnnotation:(id <MKAnnotation>) annotation{

    // if it's the user location, just return nil.
    if ([annotation isKindOfClass:[MKUserLocation class]])
        return nil;
    // try to dequeue an existing pin view first
    static NSString* AnnotationIdentifier = @"AnnotationIdentifier";
    MKAnnotationView *pinView = [[MKAnnotationView alloc]
                                  initWithAnnotation:annotation reuseIdentifier:AnnotationIdentifier];
    pinView.image = [UIImage imageNamed:@"BlueMarbleDrop"];

    pinView.annotation = annotation;
    return pinView;
}

これがBlueMarbleDrop.pngです

于 2012-10-18T09:32:29.167 に答える