【问题标题】:Positioning GMSMapView to show multiple annotations at once定位 GMSMapView 以一次显示多个注释
【发布时间】:2013-03-26 19:03:55
【问题描述】:

我的问题与this, except MKMapView. 非常相似 如何使用 Google 地图执行相同的过程(调整地图大小以一次适应屏幕上的所有注释/标记)? 据我了解,我必须将 MKCoordinateRegion 转换为 GMSProjection,我的方法对吗?

【问题讨论】:

    标签: ios google-maps


    【解决方案1】:

    很简单,就是:

    @property (nonatomic, strong) GMSMapView *mapView;
    
    - (void)didTapFitBoundsWithMarkers:(NSArray *)markers
    {
    GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];;
    
    for (GMSMarker *marker in markers) {
        bounds = [bounds includingCoordinate:marker.position];
    }
    
    GMSCameraUpdate *update = [GMSCameraUpdate fitBounds:bounds];
    [self.mapView moveCamera:update];
    [self.mapView animateToViewingAngle:50];
    }
    

    【讨论】:

    • 感谢您的关注。当我发布问题时,我在 GMapsSDK 的早期版本中找不到此方法 (includingCoordinate)。而且 API 不包含 GMSCameraUpdate
    猜你喜欢
    • 2010-11-23
    • 2013-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-12
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多