【问题标题】:Show Multiple Users Location on Google/Apple Maps with Blue Marble Drop使用 Blue Marble Drop 在 Google/Apple 地图上显示多个用户位置
【发布时间】:2012-10-18 08:32:46
【问题描述】:

所以我需要在这里做的是,我需要在地图上显示两个用户位置,并使用默认蓝色大理石掉落。

任务是,用户 A 将每 5-10 秒将当前位置坐标上传到网络服务器,然后用户 B 将每 5-10 秒从那里拉出该位置。所以在 MKMapView 上,User-B 将显示他自己的当前位置,并带有默认位置注释,但我还需要在 User-B 的 mapView 上显示 User-A 的位置并带有一些注释。

现在我不能使用 Pin Annotation,因为位置将每 5-10 秒更新一次。必须为第二个用户的拉动位置显示默认用户注释(蓝色大理石滴),以便用户可以知道第二个用户的位置不是静态的,而是移动的。 Pin Annotation 暗示该位置是静态的。

我怎样才能做到这一点?

【问题讨论】:

  • 为什么不能使用 Pin Annotation?
  • 当查看 Pin 图时,它传达的信息是该位置是静态的,比如巴士站或酒店,对于移动的物体,它并不合适。
  • 我相信带有 Pin Annotation 的自定义 pinView 会为您工作。
  • 是的,那会做..!谢谢:)

标签: iphone ios google-maps ios5 mapkit


【解决方案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;
}

【讨论】:

    猜你喜欢
    • 2015-05-16
    • 1970-01-01
    • 1970-01-01
    • 2019-10-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多