I want Minimum and Maximum Latitude and Longitude Using Current Location.Suppose i have give the area of 20km so using that latitude and Longitude i want Maximum latitude and Longitude and Minimum latitude and Longitude also want all latitude and Longitude in between this so how can i get it.How can i use of radius in it.Please help me.Thanks in Advance...
3 Answers
you can manually calculate it... I don't know if any other way exist 1° latitude = 69.047 statute miles = 60 nautical miles = 111.12 kilometers
so for 20 kilometers it would be around 0.18 latitude For longitude the conversion is the same as latitude except the value is multiplied by the cosine of the latitude.
To set the same range on map for display
newRegion.center=newLocation.coordinate;
// newRegion.span.latitudeDelta = (20*2)/111.12; // For kilometers
newRegion.span.latitudeDelta = (20*2)/60.0; // For Miles
newRegion.span.longitudeDelta = ((20*2)/60.0) *(cos(newRegion.span.latitudeDelta)); // For Miles
mapView.region = newRegion;
It will set 20 kilometer's range on map that is displayed...
so you can find it by
you can find it by
minLattitude = currentLattitude - (RadiusInKm/111.12);
maxLattitude = currentLattitude + (RadiusInKm/111.12);
For longitude same but multiply the result with cosine of latitude...

- 13,743
- 3
- 64
- 88
-
i have current location and radius now i want to find Min Lat/Long and Max Lat/Long (region) how can i find this... – Ankit Vyas Jun 18 '10 at 06:38
-
Hi Ankit, you can find it by minLattitude = currentLattitude - (RadiusInKm/111.12); maxLattitude = currentLattitude + (RadiusInKm/111.12); For logitude same but multiply the result with cosine of lattitude...I am updating the same in answer... – Mihir Mehta Jun 18 '10 at 07:28
-
double minLattitude,maxLattitude,minLongitude,maxLongitude; minLattitude = self.currentLocation.latitude - ((LOCATE_PIN_MILE*1.609344)/111.12); minLongitude = self.currentLocation.longitude * cos(minLattitude); maxLattitude = self.currentLocation.latitude + ((LOCATE_PIN_MILE*1.609344)/111.12); maxLongitude = self.currentLocation.longitude * cos(maxLattitude); Is it ok? Where LOCATE_PIN_MILE is in miles. I am not getting correct results. Please suggest me. – Ankit Vyas Jun 18 '10 at 09:45
-
use LOCATE_PIN_MILE/60 direct OR LOCATE_PIN_MILE*2/60... one of them should be work – Mihir Mehta Jun 19 '10 at 07:25
-
rad = 1Km , location = 41.650476 -0.872905 result: Mlat41.659475 mLon0.596298 mLat41.641477 MLon0.607675 . So, It is not work as a a general solution – doxsi Jun 27 '14 at 11:51
1) Macros to convert Degrees to Radians:
#define DEGREES_TO_RADIANS(degrees) (degrees / 180.0 * M_PI)
2) Macros to raduis in KM:
#define radiusInKM 5.00
3) Set the minimum and maximum Latitude, Longitude values
CLLocation *location;//your current location
1° latitude = 69.047 statute miles = 60 nautical miles = 111.12 kilometers
double minLat = location.coordinate.latitude - (radiusInKM/111.12);
double maxLat = location.coordinate.latitude + (radiusInKM/111.12);
double minLon = location.coordinate.longitude - (radiusInKM) / fabs(cos(DEGREES_TO_RADIANS(location.coordinate.longitude))*111.12);
double maxLon = location.coordinate.longitude + (radiusInKM) / fabs(cos(DEGREES_TO_RADIANS(location.coordinate.longitude))*111.12);

- 3,985
- 4
- 39
- 42

- 603
- 5
- 10
macros to convert Degrees to Radians
define DEGREES_TO_RADIANS(degrees) (degrees / 180.0 * M_PI)
macros to raduis in KM
define radiusInKM 5.00
set the minimum and maximum Latitude, Longitude values
CLLocation *location;//your current location
1° latitude = 69.047 statute miles = 60 nautical miles = 111.12 kilometers
double minLat = location.coordinate.latitude - (radiusInKM/111.12);
double maxLat = location.coordinate.latitude + (radiusInKM/111.12);
double minLon = location.coordinate.longitude - (radiusInKM) / fabs(cos(DEGREES_TO_RADIANS(location.coordinate.longitude))*111.12);
double maxLon = location.coordinate.longitude + (radiusInKM) / fabs(cos(DEGREES_TO_RADIANS(location.coordinate.longitude))*111.12);

- 603
- 5
- 10
-
Not sure how this is substantially different from the accepted answer, but at least delete one of your answers – Foon Jul 31 '15 at 12:31