Is there any way to quickly test whether an MKCoordinateRegion
is good or not? I've swapped latitude for longitude and caused an application crash. I'd like to be able to see whether it's possible to perform a setRegion
before I actually do it. Will MKCoordinateRegionMake
test the values I give it?
Thanks.
It turns out I had swapped my latitude and longitude somewhere. Here's the code I ended up using:
// check for sane span values
if (currentRegion.span.latitudeDelta <= 0.0f || currentRegion.span.longitudeDelta <= 0.0f) {
currentRegion.span.latitudeDelta = 1.0f;
currentRegion.span.longitudeDelta = 1.0f;
}
// check for sane center values
if (currentRegion.center.latitude > 90.0f || currentRegion.center.latitude < -90.0f ||
currentRegion.center.longitude > 180.0f || currentRegion.center.longitude < -180.0f
) {
// Take me to Tokyo.
currentRegion.center.latitude = 35.4f;
currentRegion.center.longitude = 139.4f;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With