iPhoneのMapKitマップのデフォルトのピンの代わりに独自のイメージを使用できますか?iPhoneのMapKitフレームワークのデフォルトのピンの代わりに画像ですか?
Google Latitudeとよく似た友だちの場所を表示し、友だちの画像をその場所に表示する必要があるアプリケーションに取り組んでいます。
JavaScriptのGoogleマップを使用することは可能ですが、誰かがMapKitベースのマップのサンプルコードを提供できるかどうかを知りたいと思っています。
iPhoneのMapKitマップのデフォルトのピンの代わりに独自のイメージを使用できますか?iPhoneのMapKitフレームワークのデフォルトのピンの代わりに画像ですか?
Google Latitudeとよく似た友だちの場所を表示し、友だちの画像をその場所に表示する必要があるアプリケーションに取り組んでいます。
JavaScriptのGoogleマップを使用することは可能ですが、誰かがMapKitベースのマップのサンプルコードを提供できるかどうかを知りたいと思っています。
はい、可能です。 そのためには、MKPinAnnotationViewの代わりにMKAnnotationViewを使用する必要があります。 、annotation.animatesDropプロパティは使用しないでください。ここで
あなたはまた、画像のフレームを設定することができannotation = [[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:@"try"];
annotation.canShowCallout = YES;
annotation.image = [UIImage imageNamed:@"image.png"];
return annotation;
、あなたがviewForAnnotationに使用できるサンプルコードです。上記のコードでは、この単純な変更を行う必要があります。
UIImage *pinImage = [UIImage imageNamed:@"image.png"];
UIImageView *imageView = [[[UIImageView alloc] initWithImage:pinImage] autorelease];
imageView.frame = CGRectMake(-20, 0, 40, 30);
[annotation addSubview:imageView];
そして、我々はあなたが簡単にあなたの必要
MKCoordinateSpanスパンにズームすることができますスパンプロパティを使用して、回線
// annotation.image = [UIImage imageNamed:@"image.png"];
をコメントに持っています。
MKCoordinateRegion region;
mapView.scrollEnabled=YES;
span.latitudeDelta = 100.0;//more value you set your zoom level will increase
span.longitudeDelta =100.0;//more value you set your zoom level will increase
mapView.showsUserLocation=YES;
region.span = span;
region.center = from.coordinate;
[mapView setRegion:region animated:YES];
[mapView regionThatFits:region];
[mapView addAnnotation:from];
ありがとうございました。それはトリックでした。私はそのようなシンプルなトリックを理解していると信じています。 –