How can i get minimum and maximum latitude and longitude using current location and radius?

后端 未结 3 1229
死守一世寂寞
死守一世寂寞 2020-12-30 17:18

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 an

3条回答
  •  感情败类
    2020-12-30 17:45

    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...

提交回复
热议问题