views:

35

answers:

0

i have a google map (MKMapview) which should be divided into regions (couple of sates of US is combined for each region and some regions composed from couple of adjacent cities) i have decided to use OVERLAYS to draw the region on the map so now in my application i have a google map with couple of Overlays

now i need to detect if the user selected one of them note the regions have a polygon shape

i tried to inherit from "MKPolylineView" and add a "touchesBegan" method to it and use the new class in the mapview delegate (the delegate is in my viewController class that contains mkmapview) the delegate is called and the new class is send without any problems

  • (MKOverlayView *) mapView:(MKMapView *)mapView viewForOverlay:(id)overlay { NSLog(@"This is called");

    GIjMKPolylineView *plv = [[[GIjMKPolylineView alloc] initWithOverlay:overlay]autorelease]; plv.strokeColor = [UIColor redColor]; plv.lineWidth = 3.0; [mapView addSubview:plv]; // Any other view twiddles you need. NSLog(@"This was called"); return plv;

}

but the touchbegins in my new class GIjMKPolylineView (inherited from MKPolylineView ) was never called

this is how i defined my overlay

{ CLLocationCoordinate2D points[5];

 points[0] = CLLocationCoordinate2DMake(41.000512, -109.050116);

points[1] = CLLocationCoordinate2DMake(41.002371, -102.052066);

points[2] = CLLocationCoordinate2DMake(36.993076, -102.041981);

points[3] = CLLocationCoordinate2DMake(36.99892, -109.045267);

points[4] = CLLocationCoordinate2DMake(41.000512, -109.050116);
MKPolygon* poly = [MKPolygon polygonWithCoordinates:points count:5];

poly.title = @"Colorado";
[mapView addOverlay: poly];

}

so anyone knows why or any solution or any other way to know a selected region on the map