1
如何(谷歌地圖iOS)獲取當前地圖視圖綁定? 我發現ios api與google map javascript api完全不同。如何(谷歌地圖iOS)獲取當前地圖視圖綁定?
如何(谷歌地圖iOS)獲取當前地圖視圖綁定? 我發現ios api與google map javascript api完全不同。如何(谷歌地圖iOS)獲取當前地圖視圖綁定?
做了一番研究後,下面是工作代碼。
// work only on real device, not work on simulator
- (void)mapView:(GMSMapView *)mapView
idleAtCameraPosition:(GMSCameraPosition *)cameraPosition {
// show current map view bound
GMSVisibleRegion visibleRegion = [mapView_.projection visibleRegion];
GMSCoordinateBounds *bounds = [[GMSCoordinateBounds alloc]initWithRegion:visibleRegion];
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);
}