gpt4 book ai didi

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

转载 作者:IT王子 更新时间:2023-10-29 07:59:53 25 4
gpt4 key购买 nike

我正在使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com