Google地图1.2.0 GMSCoordinateBounds
现在包含containsCoordinate方法,我打算用它来过滤不在visibleRegion上的标记。不幸的是,当您初始化GMSCoordinateBounds
时,您将获得包含您的区域或路径的界限。
所以我的问题是:是否可以查看CLLocationCoordinate2D
是否在GMSPath
范围内?
答案 0 :(得分:0)
所以我回答了我自己的问题。我只需要使用pointForCoordinate方法来查看该点是否在屏幕上。效果很好。
for (int i = 0; i < self.visibleLocations.count; i++) {
Location *location = [self.visibleLocations objectAtIndex:i];
CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake([location.lat floatValue], [location.lng floatValue]);
CGPoint markerPoint = [self.googleMap.projection pointForCoordinate:coordinate];
if (markerPoint.x >= 0 && markerPoint.y >= 0 && markerPoint.x <= self.googleMap.frame.size.width && markerPoint.y <= self.googleMap.frame.size.height) {
GMSMarker *marker = [GMSMarker markerWithPosition:coordinate];
marker.title = location.title;
marker.icon = [UIImage imageNamed:@"search_measle_small.png"];
marker.map = self.googleMap;
}
}