iPhone MapKit-更新注释坐标和地图 [英] iPhone MapKit - update annotations coordinates and map

查看:57
本文介绍了iPhone MapKit-更新注释坐标和地图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用本教程将MapKit集成到我的应用程序中: http://iphonebcit.wordpress.com/iphone -map-kit-tutorial/

I use this tutorial for integrating MapKit to my application: http://iphonebcit.wordpress.com/iphone-map-kit-tutorial/

CLLocationCoordinate2D coordinate;
coordinate.latitude = 49.2802;
coordinate.longitude = -123.1182;

NSUInteger count = 1;
for(int i = 0; i < 10; i++) {
    CGFloat latDelta = rand()*.035/RAND_MAX - .02;
    CGFloat longDelta = rand()*.03/RAND_MAX - .015;

    CLLocationCoordinate2D newCoord = {coordinate.latitude+latDelta, coordinate.longitude+longDelta};
    MapDemoAnnotation* annotation = [[MapDemoAnnotation alloc] initWithCoordinate:newCoord andID:count++];
    [mapView addAnnotation:annotation];
    [annotation release];
}

- (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation {
MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapViewLocal dequeueReusableAnnotationViewWithIdentifier:@"Pin"];
if(pinView == nil) {
    pinView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"Pin"];
    pinView.pinColor = MKPinAnnotationColorPurple;
    pinView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
    pinView.animatesDrop = YES;
    pinView.canShowCallout = YES;
} else {
    pinView.annotation = annotation;
}
return pinView;

}

因此,图钉将随机设置在地图上.在我的应用程序中,坐标将改变.如何更改注释的坐标,以便在地图上对其进行更新?

So the pins will set on the map randomly. In my application, the coordinates will change. How can I change the coordinates of the annotations, so they will be updated on the map?

有人知道吗?

推荐答案

在iPhone SDK 3.x中,您必须删除引脚注释并重新设置.如果您的地图上有很多注释,那不是很好.

At iPhone SDK 3.x you have to remove the pin annotations and set it again. That is not very nice if you have many annotations an your map.

我试图使其变得更好,所以我只能显示/更新屏幕上的图钉注释.因此,如果用户放大到纽约,那么旧金山将没有别针注释,或者用户看不到其他注释.这样性能会好很多.

I try to make it better so I ony display/renew my pin annotations which are on the screen. So if an user zoom in to New York, there won't be pin annotations in San Francisco or other than the user can't see. So the performance will be much better.

也许将来有可能.我希望是这样:-)

Perhaps in the future this would be possible. I hope so :-)

这篇关于iPhone MapKit-更新注释坐标和地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆