获取地图边界的两种办法

– (IBAction)getBounds:(id)sender{

    MKMapRect mRect =
self.mapview.visibleMapRect;

    MKMapPoint neMapPoint =MKMapPointMake(MKMapRectGetMaxX(mRect), mRect.origin.y);

    MKMapPoint swMapPoint =MKMapPointMake(mRect.origin.x,MKMapRectGetMaxY(mRect));

    CLLocationCoordinate2D neCoord =MKCoordinateForMapPoint(neMapPoint);

    CLLocationCoordinate2D swCoord =MKCoordinateForMapPoint(swMapPoint);

    NSLog(@”neCood:%f,%f”,neCoord.latitude,neCoord.longitude);

    NSLog(@”swCood:%f,%f”,swCoord.latitude,swCoord.longitude);

      

}

– (IBAction)getBounds:(id)sender{

//To calculate the search bounds...
//First we need to calculate the corners of the map so we get the points
CGPoint nePoint = CGPointMake(self.mapView.bounds.origin.x + mapView.bounds.size.width, mapView.bounds.origin.y);
CGPoint swPoint = CGPointMake((self.mapView.bounds.origin.x), (mapView.bounds.origin.y + mapView.bounds.size.height));

//Then transform those point into lat,lng values
CLLocationCoordinate2D neCoord;
neCoord = [mapView convertPoint:nePoint toCoordinateFromView:mapView];

CLLocationCoordinate2D swCoord;
swCoord = [mapView convertPoint:swPoint toCoordinateFromView:mapView];

转载自:https://blog.csdn.net/edward0004/article/details/7472666

You may also like...