在图钉中放置图钉后,如何更新/更改其颜色?
|
我正在做一个贴文,将图钉/注释放在mapview中。当用户接近别针时,我希望别针改变颜色。一切正常,将销钉放置在我想要的位置,当距离足够近时,我会收到一条警报消息。但是我不确定如何更新图钉颜色。我是否需要删除注释并替换它们?似乎不必要,我要寻找的只是某种更新/刷新mapview,而不必替换注释。
CLLocation *place =[[CLLocation alloc] initWithCoordinate:location altitude:1 horizontalAccuracy:1 verticalAccuracy:-1 timestamp:nil];
AddresAnnotation *ann = [[AddresAnnotation alloc] initWithCoordinate:place.coordinate];
[ann setTitle:[rows placeName]];
[mapView addAnnotation:ann];
location是CLLocationCoordinate2D
行是一个包含不同位置及其信息的对象
这是mapView委托方法:(不确定最后一个\“} \”为什么不在代码示例中)
-(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
if (annotation != self.mapView.userLocation) {
annView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@\"Plats\"] autorelease];
[annView setPinColor:MKPinAnnotationColorRed];
annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
return annView;
} else {
zoomButton.enabled = TRUE;
return nil;
}
}
没有找到相关结果
已邀请:
1 个回复
程琶
基本上,创建一个循环,将搜索一系列位置。有它 [mapView.userLocation.location distanceFrom:prox] /1609.334 // prox表示一个位置实例,该实例经过测试以查看是否在用户的x英里之内。 然后说