【问题标题】:Refresh my mapView刷新我的地图视图
【发布时间】:2010-03-10 10:36:27
【问题描述】:

我有一个带有大头针的 mapView,以及我与地图上其他点之间的 CLLocation 和 getDistance 的以下代码:

    - (void)locationManager:(CLLocationManager *)manager
    didUpdateToLocation:(CLLocation *)newLocation
           fromLocation:(CLLocation *)oldLocation{

 Koordinate *kunde = [[Koordinate alloc] init];
 kundenPoints = [[NSMutableArray array] retain];

 for(int i = 0; i<[eventPoints count]; i++){
  kunde = [eventPoints objectAtIndex:i];
  CLLocation *userLoc = [[CLLocation alloc] initWithLatitude:kunde.latitude longitude:kunde.longtitude];
  double distance = [newLocation getDistanceFrom:userLoc] / 1000;
  if(distance <= 100){
   [kundenPoints addObject:kunde];
  }else {
  }
 }
 [mapView addAnnotations:kundenPoints];
}

但是当我点击按钮时如何实现刷新地图的方法? 当我想要的时候,我总是把别针放在我身边。 按钮不是问题,只有刷新!

希望有人能帮帮我??

最好的问候 马可

【问题讨论】:

    标签: iphone mkmapview cllocationmanager mkpinannotationview


    【解决方案1】:

    据我所知,没有 removeAllAnnotations 这样的东西,至少在 iOS4 SDK 中没有……尽管您可以使用

    快速修复它
    NSArray *ants = [mapView_ annotations];
    [mapView_ removeAnnotations:ants];
    

    叠加层也是如此

    NSArray *ants = [mapView_ overlays];
    [mapView_ removeOverlays:ants];
    

    到目前为止,这是我发现的最好的方法。

    【讨论】:

      【解决方案2】:

      只需 removeAllAnnotations 到您的 mapView 并添加新的,这将刷新您地图上的注释。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-09-03
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多