ios - 从谷歌地图 iOS 中删除标记

标签 ios mapkit google-maps-markers google-maps-sdk-ios

我正在使用 Storyboard和 Google map 构建一个 iOS 应用程序。使用 iOS6

我的应用程序具有在 facebook 应用程序中看到的 Split View导航

在我的左 View 中,我在列表中选择了一个具有纬度/经度线的项目,并按照以下方法将其显示在我的 map 上

- (void)viewWillAppear:(BOOL)animated

我想在添加另一个标记之前删除此方法中的所有标记(因此 map 上只有一个标记),有没有办法做到这一点?下面是我向 mapView 添加标记的代码

提前致谢 - 乔恩

- (void)loadView
{
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:poi.lat
                                                            longitude:poi.lon
                                                                 zoom:15];
    mapView = [GMSMapView mapWithFrame:CGRectZero camera:camera];

    mapView.myLocationEnabled = YES;
    self.view = mapView;
    mapView.mapType = kGMSTypeHybrid;

    //Allows you to tap a marker and have camera pan to it
    mapView.delegate = self;
}

-(void)viewWillAppear:(BOOL)animated
{
    GMSMarkerOptions *options = [[GMSMarkerOptions alloc] init];
    options.position = CLLocationCoordinate2DMake(poi.lat, poi.lon);
    options.title =  poi.title;
    options.snippet = poi.description;
    options.icon =  [UIImage imageNamed:@"flag-red.png"];
    [mapView addMarkerWithOptions:options];

    [mapView animateToLocation:options.position];
    [mapView animateToBearing:0];
    [mapView animateToViewingAngle:0];
}

最佳答案

删除所有标记

mapView.clear()

删除特定标记

myMarker.map = nil

关于ios - 从谷歌地图 iOS 中删除标记,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16067575/

相关文章:

javascript - 在 Google Maps API v3 中使用单独的删除按钮绘制圆形/多边形

javascript - 如何显示 alert() 关闭谷歌地图 'marker' 点击?

css - 使用 Google Maps API 将 CSS 阴影添加到标记

ios - 搜索功能解析 IOS

ios - 在 iPhone 上分析 CPU 指令

iphone - 如何在 map 注释 View 中找出引脚 ID?

swift - 如何在 Swift 4.2 中的 Mapkit 上设置坐标轴

ios - swift 3 : Is there a way to cast an object to a class and protocol at the same time?

objective-c - 将触摸事件添加到 UIVIew 并将 UIView 的实例传递给被调用的选择器

ios - 如何在后台使用 MKMapSnapshotter?