刷新我的地图查看

发布于 2024-08-24 13:09:32 字数 830 浏览 7 评论 0原文

我有一个带有图钉的地图视图,以及我和地图上其他点之间的 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];
}

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

我希望有人能帮助我?

此致 马可

i have a mapView with pins on it, and the following code for CLLocation and getDistance between me and another points on the map:

    - (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];
}

but how can i implement a method that refreshes the map when i tab on a button?
that i always get the pins around me when i want.
the button is not the problem, only the refresh!

i hope someone could help me??

best regards
Marco

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

冰葑 2024-08-31 13:09:32

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

NSArray *ants = [mapView_ annotations];
[mapView_ removeAnnotations:ants];

覆盖层相同的方法

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

快速修复它,但到目前为止这是我发现的最好方法。

as far as I know there is no such a thing as removeAllAnnotations, at least not in iOS4 SDK... although you can quickly fix it using

NSArray *ants = [mapView_ annotations];
[mapView_ removeAnnotations:ants];

same goes for overlays

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

so far is the best way I've found to do it.

为你拒绝所有暧昧 2024-08-31 13:09:32

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

Just removeAllAnnotations to your mapView and add the new ones, this will refresh the annotations on your map.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文