Mapbox-ios如何删除MGLFeature
我通过visibleFeaturesInRect
得到了一个有作用域的MGLFeature对象,因为这些对象可能是MGLPolygonFeature
,MGLPolylineFeature
等。我不知道它是什么,所以我想直接删除它通过removeLayer
。
通过:
if (features.count > 0) {
for (id<MGLFeature> feature in features) {
MGLStyleLayer * layer = feature;
[self.mapView.style removeLayer:layer];
}
}
我们找到的数据:
<MGLPolygonFeature: 0x600000f20310; identifier = "china.18", count = 113, bounds = { sw = {26.9, 78.4}, ne = {36.5, 99.1}}, attributes = {
ADCODE93 = 540000;
ADCODE99 = 540000;
AREA = "114.331";
"BOU2_4M_" = 179;
"BOU2_4M_ID" = 54;
NAME = "\U897f\U85cf\U81ea\U6cbb\U533a";
PERIMETER = "76.629";
}>,
<MGLPolygonFeature: 0x600000f20150; identifier = "china.18", count = 113, bounds = { sw = {26.9, 78.4}, ne = {36.5, 99.1}}, attributes = {
ADCODE93 = 540000;
ADCODE99 = 540000;
AREA = "114.331";
"BOU2_4M_" = 179;
"BOU2_4M_ID" = 54;
NAME = "\U897f\U85cf\U81ea\U6cbb\U533a";
PERIMETER = "76.629";
}>
原因:“-[MGLPolygonFeature rawLayer]:无法识别的选择器已发送至 实例0x6000009400e0'