I am doing a map based application in iphone. I get my data(address) from the addressbook. The locations are pinned correctly when the right address is provided. But when a wrong address(like XYZ instead of a correct city name like New York) is entered the pins fall to the (0,0) co ordinate of the map or to some random location in Canada. How can I handle this case.
You could check for an invalid coordinate using the kCLLocationCoordinate2DInvalid constant, something like:
if ((coord.latitude == kCLLocationCoordinate2DInvalid.latitude) || (coord.longitude == kCLLocationCoordinate2DInvalid.longitude))
{
NSLog(@"Invalid coordinate");
}
else
{
// Valid coordinate, add it to the map
}
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