小编jch*_*853的帖子

从Google地图iOS中删除标记

我正在使用故事板和Google地图构建iOS应用程序.使用iOS6

我的应用程序具有在Facebook应用程序中看到的拆分视图导航

在我的左视图中,我选择列表中的项目,该项目具有纬线/长线,并在我的地图上通过以下方法显示

- (void)viewWillAppear:(BOOL)animated

我想在添加另一个标记之前删除此方法中的所有标记(因此地图上只有一个标记),有没有办法做到这一点?下面是我在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];
}
Run Code Online (Sandbox Code Playgroud)

mapkit google-maps-markers ios google-maps-sdk-ios

23
推荐指数
4
解决办法
3万
查看次数