マップビューでは、現在のユーザーの場所を表示しています。ピンをクリックして "Current Location"を表示します。私はそれを "My Current Location"に変更したいと思います。どうすれば変更できますか? また、タイマーで現在のユーザーの位置ピンの色を変更したいとします。緑、紫、赤の間で色を変えなければならないようなものがあります。それは可能ですか?iPadマップキット - 現在の場所のタイトルを変更する
私はマップキットのショーのデフォルトの場所を使用して、以下のように注釈ピンの色を操作しています:
- (MKAnnotationView *)mapView:(MKMapView *)map viewForAnnotation:(id <MKAnnotation>)annotation{
static NSString *AnnotationViewID = @"annotationViewID";
SolarAnnotationView* annotationView = (SolarAnnotationView*)[map dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID];
if(annotationView == nil)
{
if([self CLLocationCoordinate2DEquals:mapView.userLocation.location.coordinate withSecondCoordinate:[annotation coordinate]]) //Show current location with green pin
{
annotationView = [[SolarAnnotationView alloc] initWithAnnotation:annotation];
annotationView.delegate = self;
[annotationView setPinColor:MKPinAnnotationColorGreen];
}
else
{
annotationView = [[SolarAnnotationView alloc] initWithAnnotation:annotation];
annotationView.delegate = self;
}
}
return annotationView;
}
- (BOOL) CLLocationCoordinate2DEquals:(const CLLocationCoordinate2D)lhs withSecondCoordinate:(const CLLocationCoordinate2D) rhs{
const CLLocationDegrees DELTA = 0.001;
return fabs(lhs.latitude - rhs.latitude) <= DELTA && fabs(lhs.longitude - rhs.longitude) <= DELTA;
}
表示:
は、このようなviewForAnnotation方法を変更します。マップビューのshowsUserLocationプロパティを使用してデフォルトの青い点を得るかカスタムピンを作成していますか?アノテーションとviewForAnnotationメソッドの追加方法を示します。 – Anna