Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handling wrong address in mapview

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.

like image 927
Jean Paul Scott Avatar asked Sep 10 '26 03:09

Jean Paul Scott


1 Answers

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
}
like image 74
Marco Avatar answered Sep 11 '26 17:09

Marco