我在使用适用于 iOS 的 Google Maps SDK(版本 1.5.0)绘制多个标记时遇到问题。我是 Objective c(使用 Xcode 4.6.3 版)和 Google Maps SDK 的新手,所以我可能会遗漏一些明显的东西。我也在使用 iOS 6.1 模拟器。我正在尝试边做边学。
我花了几天时间搜索并找到了几个处理这个主题的线程,但没有一个解决方案适合我。我遇到的问题是我的标记相互覆盖。我创建了一个 NSArray,locations,它将有 4 列和未知的行。列是纬度、经度、名称、地址。
for(int i=0;i<[locations count];i++){
    GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:40.0823
                                                        longitude:-74.2234
                                                             zoom:7];
    mapView_ = [GMSMapView mapWithFrame:CGRectZero camera:camera];
    self.view = mapView_;
    mapView_.myLocationEnabled = YES;
    mapView_.mapType = kGMSTypeHybrid;
    mapView_.settings.myLocationButton = YES;
    mapView_.settings.zoomGestures = YES;
    mapView_.settings.tiltGestures = NO;
    mapView_.settings.rotateGestures = NO;
    NSString *lat = [[locations objectAtIndex:i] objectAtIndex:0];
    NSString *lon = [[locations objectAtIndex:i] objectAtIndex:1];
    double lt=[lat doubleValue];
    double ln=[lon doubleValue];
    NSString *name = [[locations objectAtIndex:i] objectAtIndex:2];
    NSMutableArray *markersArray = [[NSMutableArray alloc] init];
        GMSMarker *marker = [[GMSMarker alloc] init];
        marker.appearAnimation=YES;
        marker.position = CLLocationCoordinate2DMake(lt,ln);
        marker.title = name;
        marker.snippet = [[locations objectAtIndex:i] objectAtIndex:3];
        marker.map = mapView_;
       [markersArray addObject:marker];
}