如何检查折线是否已添加到地图中?
我已经尝试了以下代码,但它似乎不起作用
for (MKPolyline *feature1 in self.mapView.overlays) {
NSLog(@"feature1.title: %@", feature1.title);
NSLog(@"Polu.title: %@", polu.title);
if (![feature1.title isEqualToString:polu.title]) {
NSLog(@"NOT");
[self.mapView addOverlay:polu];
}
else {
NSLog(@"Already added");
}
}
}
我也试过这个:
if (![self.mapView.overlays containsObject:polu]) {
NSLog(@"NOT");
[self.mapView addOverlay:polu];
}