1

我有一个带有许多具有不同图像的图钉的地图视图!一切正常,但如果我更改地图类型...正常..卫星或 ibrid..我失去了我的形象,我的别针变成了标准的红色别针!我可以更改地图类型而不更改任何内容吗?

我使用此代码分配不同的图像:

- (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 回答