I have downloaded this code. I want to check whether the users current location belongs to any of the region. For that i have called following method but its always returning FALSE. Below is my code:
-(void)checkPoint
{
CLLocationCoordinate2D mapCoordinate ;
mapCoordinate.longitude=34.54664654;
mapCoordinate.latitude=-117.05646;
NSMutableArray *overlays = (NSMutableArray *)[HHLViewController usStatesAndTerritoryOverlays];
MKMapPoint mapPoint = MKMapPointForCoordinate(mapCoordinate);
for (int i=0; i<[overlays count]; i++)
{
MKOverlayView *overlayview = (MKOverlayView *)[self.stateMapView viewForOverlay:[overlays objectAtIndex:i]];
MKPolygonView *polygonView =[[MKPolygonView alloc] initWithOverlay:overlayview.overlay];
CGPoint polygonViewPoint = [polygonView pointForMapPoint:mapPoint];
BOOL mapCoordinateIsInPolygon =
CGPathContainsPoint(polygonView.path, NULL, polygonViewPoint, NO);
NSLog(@"polygon is inside %d",mapCoordinateIsInPolygon);
}
}
My problem is i want always getting NO value in mapCoordinateIsInPolygon
eventhough the point belongs to that region.
I dont want to display map so any other options are also welcomed.