1

さまざまな画像のピンがたくさんあるマップビューがあります。すべてうまくいきますが、マップタイプを変更すると...通常..衛星またはイブリッド..画像が失われ、ピンが標準の赤いピンになりました。何も変更せずにマップタイプを変更できますか?

このコードを使用して、さまざまな画像を割り当てます。

- (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id  <MKAnnotation>)annotation
{
annView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:nil];

if([annotation.title compare:@"Biggest"]==0){imageView = [UIImage imageNamed:@"pin.png"];annView.image=imageView;}
if([annotation.title compare:@"Campo sportivo"]==0){imageView = [UIImage imageNamed:@"mondo.png"];annView.image=imageView;}
if([annotation.title compare:@"BlackSheep ADV"]==0){imageView = [UIImage    imageNamed:@"an.png"];annView.image=imageView;}


annView.pinColor = MKPinAnnotationColorRed;
UIButton *advertButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];

[advertButton addTarget:self action:@selector(button:)       forControlEvents:UIControlEventTouchUpInside];
annView.rightCalloutAccessoryView = advertButton;

annView.animatesDrop = TRUE;
annView.canShowCallout = YES;
annView.calloutOffset = CGPointMake(0, 5);

if ([annotation isKindOfClass:[MKUserLocation class]]){
                                                    return nil;
                                                  }
return annView;

}
4

1 に答える 1

3
    - (void) changeMapType: (id)sender
    {
        if (mapView.mapType == MKMapTypeStandard)
            mapView.mapType = MKMapTypeSatellite;
        else
            mapView.mapType = MKMapTypeStandard;
    } 

This method works as according to google maps have two types
1) standard
2) satellite

So by default if you use google maps, it is in the form of MKMapTypeStandard you can change if you want by             mapView.mapType = MKMapTypeSatellite;
于 2012-11-07T19:22:36.633 に答える