【发布时间】:2014-03-04 03:50:44
【问题描述】:
我想显示地图上的所有标记,在进行了一些搜索后,我发现应该使用 GMSCoordinateBounds(Google Maps SDK)来完成我已经阅读了有关它的官方文档,但我不明白如何使用它并在我的代码中实现它。
这是我的代码
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] init];
CLLocationCoordinate2D location;
for (NSDictionary *dictionary in array) {
location.latitude = [dictionary[@"latitude"] floatValue];
location.longitude = [dictionary[@"longitude"] floatValue];
// Creates a marker in the center of the map.
GMSMarker *marker = [[GMSMarker alloc] init];
marker.icon = [UIImage imageNamed:(@"marker.png")];
marker.position = CLLocationCoordinate2DMake(location.latitude, location.longitude);
bounds = [bounds includingCoordinate:marker.position];
marker.title = dictionary[@"type"];
marker.map = mapView_;
}
[mapView_ animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds withPadding:30.0f]];
有什么帮助吗?
【问题讨论】:
-
能否将我的回答标记为已接受?
标签: ios google-maps google-maps-sdk-ios