【发布时间】:2023-03-15 20:10:02
【问题描述】:
我使用 MapView 并在其上设置注释(紫色大头针)和我的用户位置(蓝色圆圈)。 因为紫色的大头针注释会移动,所以我必须删除它们并将它们设置为新的地图。
我设置为:
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};
MyMapAnnotation* annotation = [[MyMapAnnotation alloc] initWithCoordinate:newCoord andID:count++];
[mapView addAnnotation:annotation];
[annotation release];
}
在那之前,我做了一个
[mapView removeAnnotations:mapView.annotations];
但是这条线也用蓝点删除了我的位置! 如果不删除我的位置,我怎么能做到这一点。
非常感谢提前和最好的问候。
【问题讨论】:
标签: iphone mkmapview mkpinannotationview