我想只在屏幕的可见区域显示可见标记,但我只得到-180个值。在模拟器和iPad设备上的结果相同。
代码:
GMSVisibleRegion visibleRegion = [mapView.projection visibleRegion];
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc]initWithRegion:visibleRegion];
[mapView animateWithCameraUpdate:[GMSCameraUpdate fitBounds:bounds]];
CLLocationCoordinate2D northEast = bounds.northEast;
CLLocationCoordinate2D northWest = CLLocationCoordinate2DMake(bounds.northEast.latitude, bounds.southWest.longitude);
CLLocationCoordinate2D southEast = CLLocationCoordinate2DMake(bounds.southWest.latitude, bounds.northEast.longitude);
CLLocationCoordinate2D southWest = bounds.southWest;
NSLog(@"NORTH-EST: %.5f",northEast.latitude);
NSLog(@"NORTH-EST: %.5f",northEast.longitude);
NSLog(@"NORTH-WEST: %.5f",northWest.latitude);
NSLog(@"NORTH-WEST: %.5f",northWest.longitude);
NSLog(@"South-EST: %.5f",southEast.longitude);
NSLog(@"South-EST: %.5f",southEast.latitude);
NSLog(@"SOUTH-WEST: %.5f",southWest.latitude);
NSLog(@"SOUTH-WEST: %.5f",southWest.longitude);
日志:
Printing description of visibleRegion:
(GMSVisibleRegion) visibleRegion = {
nearLeft = (latitude = -180, longitude = -180)
nearRight = (latitude = -180, longitude = -180)
farLeft = (latitude = -180, longitude = -180)
farRight = (latitude = -180, longitude = -180)
}
答案 0 :(得分:2)
找到解决此问题的方法:
源代码:
GMSVisibleRegion visibleRegion = [mapView.projection visibleRegion];
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc]initWithRegion:visibleRegion];
CLLocationCoordinate2D northEast = bounds.northEast;
CLLocationCoordinate2D southWest = bounds.southWest;
visibleRegion仅适用于模拟器上的真实设备IOS设备。