刷新我的地图查看
我有一个带有图钉的地图视图,以及我和地图上其他点之间的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,没有removeAllAnnotations这样的东西,至少在iOS4 SDK中没有...尽管您可以使用与
覆盖层相同的方法
快速修复它,但到目前为止这是我发现的最好方法。
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
same goes for overlays
so far is the best way I've found to do it.
只需
removeAllAnnotations
到您的地图视图并添加新的,这将刷新地图上的注释。Just
removeAllAnnotations
to your mapView and add the new ones, this will refresh the annotations on your map.