【发布时间】:2013-04-10 15:50:40
【问题描述】:
我正在使用故事板和 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];
}
【问题讨论】:
标签: ios mapkit google-maps-markers google-maps-sdk-ios