Greetings, I have been into iOS for only 1.5 months now and I hope Im not asking a question that was already answered here. Here it is:
I have tableview that lists some duration times which each belongs to an overlay that contains coordinates with timestamps:
for (NSUInteger i = 0; i < [dataset count]; i++)
{
crumbPath = [[CrumbPath alloc] initWithCenterCoordinate:mapView.userLocation.coordinate]; //crumbPath is my overlay
NSDictionary *route = [dataset objectAtIndex:i];
NSArray *points = [route objectForKey:@"Points"];
for (NSUInteger j = 0; j < [points count]; j++)
{
NSDictionary *point = [points objectAtIndex:j];
float latitude = (float)([[point objectForKey:@"Latitude"] doubleValue]/1000000);
float longitude = (float)([[point objectForKey:@"Longitude"] doubleValue]/1000000);
CLLocationCoordinate2D tempCoord = CLLocationCoordinate2DMake(latitude, longitude);
[crumbPath addCoordinate:tempCoord];
}
[mapView addOverlay:crumbPath];
[crumbPath release];
}
As far as I have learned, I could list that durations on my tableview, what I would like to do now is, with tableView:didSelectRowAtIndexPath method i guess, to show the overlay whose duration is tapped on the tableview. Right now, my overlays all show up on mapview, i want to show only the one that is selected.
Thanks in advance!
Ali
Posting my answer to my forgotten question.
Inside tableView:didSelectRowAtIndexPath:
, i simply removed all the overlays first and added the selected one whose index i get from the tableview.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.mapView removeOverlays:crumbs]; //crumbs - overlay array
[self.mapView addOverlay:[crumbs objectAtIndex:[indexPath row]]];
}
- (void)removeOverlay:(id < MKOverlay >)overlay
可用于删除您不想再显示的内容。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.