0

在地图上显示 Pins 之前,我必须确保将它们从地图中删除,以便它永远不会过度显示,因为显示的过程放在viewWillAppear方法中。我的相关代码是这样的:

    -(void)viewWillAppear:(BOOL)animated{

            //before doing anything, i want to remove all Pins
            RMMarkerManager *markerManager=[mapView markerManager];
            [mapView setDelegate:self];
        [mapView setBackgroundColor:[UIColor grayColor]];
        [mapView moveToLatLong:currentLocation];
        [mapView.contents setZoom: 13];
        [self.view addSubview:mapView];
        RMMarker *marker=[[RMMarker alloc] initWithUIImage:[UIImage imageNamed:@"marker-blue.png"]];
        [marker setTextForegroundColor:[UIColor blueColor]];
        [marker changeLabelUsingText:@"Vous êtes ici"];
        [markerManager addMarker:marker
                       AtLatLong:currentLocation];
    [marker release];
    }

请问我该怎么做?提前谢谢

4

1 回答 1

1

它可以通过调用 的removeMarkers方法来完成RMMarkerManager,所以它将是这样的:

-(void)viewWillAppear:(BOOL)animated{

    //remove all markers before starting    
    RMMarkerManager *markerManager=[mapView markerManager];
    [markerManager removeMarkers];

    //do what ever you want...

}
于 2011-08-15T08:31:45.360 回答