9

2時間グーグルした後、答えが見つからなかったので、これが私の最後のショットです。

mkmapviewのユーザーの現在の場所にカスタムアノテーションを使用したいと思います。しかし、私はまた、その周りに青い精度の円を置きたいと思っています。

これはできますか?

そうでない場合は、デフォルトの青い点に丸で呼び出しを追加できますか?

これが必要な理由は、私のアプリでは、現在の場所のドットが他のアノテーションの下に表示されないことが多いためです。そのため、現在の場所としてコールアウト付きの紫色のピンを使用しています。

アノテーションのコードは次のとおりです。

if ([annotation isKindOfClass:MKUserLocation.class]) 
    {
        MKPinAnnotationView *userAnnotationView = (MKPinAnnotationView *)[self.mapView dequeueReusableAnnotationViewWithIdentifier:@"UserLocation"];
        if (userAnnotationView == nil)  {
            userAnnotationView = [[[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"UserLocation"]autorelease];
        }            
        else 
            userAnnotationView.annotation = annotation;

        userAnnotationView.enabled = YES;
        userAnnotationView.animatesDrop = NO;
        userAnnotationView.pinColor = MKPinAnnotationColorPurple;
        userAnnotationView.canShowCallout = YES;
        [self performSelector:@selector(openCallout:) withObject:annotation afterDelay:0.01];

        return userAnnotationView;  
    }

アドバイスありがとうございます。乾杯、クリスチャン

4

1 に答える 1

7

OK、カスタム通知を削除しましたが、自動的にポップアップするコールアウトを追加しました。このような:

mapView.showsUserLocation=TRUE;
mapView.userLocation.title = NSLocalizedString (@"Here am I",@"Here am I" );
[self performSelector:@selector(openCallout:) withObject:mapView.userLocation afterDelay:3.0];

と:

- (void)openCallout:(id<MKAnnotation>)annotation {
    [mapView selectAnnotation:annotation animated:YES];
}

遅延がなければ、コールアウトは表示されません。

于 2010-06-23T20:55:54.880 に答える