Tim*_*ley 6 google-maps objective-c ios google-maps-sdk-ios
是否可以检查GMSPath的一部分是否在可见区域?
路径由坐标组成.mapview有一个可见区域.您可以轻松检查坐标是否在某个区域内,甚至不会进入像素空间:
- (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");
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用pointForCoordinatemapview的方法来查看路径的给定点是否会出现在屏幕上
for (int i = 0; i < path.count; i++) {
CLLocationCoordinate2D coordinate=[path coordinateAtIndex:i];
CGPoint markerPoint = [mapView_.projection pointForCoordinate:coordinate];
if (markerPoint.x >= 0 && markerPoint.y >= 0 && markerPoint.x <= mapView_.frame.size.width && markerPoint.y <= mapView_.frame.size.height) {
NSLog(@"Visible");
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2239 次 |
| 最近记录: |