在地图上显示之前删除图钉

发布于 2024-11-29 17:26:40 字数 888 浏览 1 评论 0原文

在地图上显示 Pin 图之前,我必须确保将它们从地图上删除,这样它就不会过度显示,因为显示的过程是放在 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];
    }

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

before displaying Pins on the map, i have to make sure to remove them from the map so that it will never be over displayed because the procedure of displaying is placed in the viewWillAppear method. My relevant code is this :

    -(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];
    }

How can i do that please? thanx in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

羁绊已千年 2024-12-06 17:26:40

只需调用 RMMarkerManagerremoveMarkers 方法即可完成,因此将是这样的:

-(void)viewWillAppear:(BOOL)animated{

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

    //do what ever you want...

}

It can just be done by calling the removeMarkers method of the RMMarkerManager, so it will be this :

-(void)viewWillAppear:(BOOL)animated{

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

    //do what ever you want...

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文