Google Maps iOS SDK check if path is in visible region
google-maps, google-maps-sdk-ios, ios, objective-c
Solution
The path is made up of coordinates. And the mapview has a visible Region. You can easily check if a coordinate is in a region eithout even going to pixelspace:
- (void)checkPath:(GMSPath*)path {
GMSVisibleRegion visibleRegion = _googleMap.projection.visibleRegion;
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc] initWithRegion: visibleRegion];
for(int i = 0; i < path.count; i++) {
CLLocationCoordinate2D coordinate=[path coordinateAtIndex:i];
if([bounds containsCoordinate:coordinate]) {
NSLog("Visible");
}
}
}
Problem
Is it possible to check if a part of GMSPath is in a visible region?