Saturday 15 January 2011

iphone - How to get left-top and right-bottom latitude and longitude of map in MapKit -


How to obtain the left-top and right-bottom latitude and map latitude in the Map Kit? I use this code, but it does not work properly How should I fix this?

  MKCoordinateRegion area = [map area]; Double topl, topgie, bottom, bottom; // If the latitude = 55 and the latitude delta = 126 is the top L-118 and it will not be at the top, it will be at the bottom of the screen = field. Center.latitude + region.span.latitudeDelta / 2; Headgear = Area center. Lame - area span.longitudeDelta / 2; CLLocationCoordinate2D lt; Lt.latitude = TOPL; Lt.longitude = topG; Annotation = [annotation new]; Annotation.cordinate = lt; Annotation.title = @ "Left"; [Add annotation map: annotation]; [Annotation release]; // If the latitude = 55 and the latitude delta = 126 is the floor L-7.23 and it will not be below, it will be below the bottom bottom of the screen = area Center.latitude - region.span.latitudeDelta / 2; Bottom G = Area center. Lame + area span.longitudeDelta / 2; CLLocationCoordinate2D RB; Rb.latitude = bottomL; Rb.longitude = bottomG; Annotation = [annotation new]; Annotation.cordinate = rb; Annotation. Title = @ "right"; [Add annotation map: annotation]; [Annotation release];  

One very easy way to get those coordinates is ... Use your view, and convert:

  CLLocationCoordinate2D top lift, right down; TopLeft = [mapView Convert Points: CGPointMake (0, 0) toCoordinateFromView: mapView]; CG point pointbootmrite = CGPXMake (map view.frame.image.width, mapView.frame.size.height); Right below = [View map Convert Point: Pointbottom Right to Coordinate Frameview: Map View];  

No comments:

Post a Comment