2016-04-15 28 views
1

我有這個按鈕,應該顯示/隱藏我地圖上的某些註釋引腳。我在下面有這個功能,但是當你按下它去除引腳時,它會刪除所有引腳。它應該只刪除addAttractionPinsBilka中的引腳?我能做些什麼來做到這一點?不要刪除我的地圖上的所有註釋

這裏是我的代碼:

@IBAction func bilkaAction(sender: AnyObject) { 
    if !annotationBilkaIsVisible { 
     addAttractionPinsBilka() 
     annotationBilkaIsVisible = true 

    }else { 
     map.removeAnnotations(map.annotations) 
     annotationBilkaIsVisible = false 
    } 
} 

希望你能幫助我:-)

+0

以下代碼r emoves all annotations: 'map.removeAnnotations(map.annotations)' 'addAttractionPinsBilka()'中添加了哪些註釋?您必須只刪除那種註釋。 –

+0

@AndreasBauer不少,這些都是addAttractionPinsBilka()內:'讓bilka1 =藝術品(標題: 「Bilka,Hillerød的」, LOCATIONNAME: 「Tryk爲魯特」, 紀律: 「Butik」, 座標:CLLocationCoordinate2D(北緯:55.931326,經度:12.284186))' –

+0

好的註釋是'Artwork'類型的。請參閱下面的答案。希望有所幫助。 –

回答

0

比方說,你在addAttractionPinsBilka()添加註解類型的Artwork

下面的代碼刪除所有註釋該類型

for annotation in map.annotations where annotation is Artwork { 
    map.removeAnnotation(annotation) 
} 
相關問題