0

So I have this code that will show all the annotation when I press the button. What I'm trying to do is to show each annotation by its type with multiple buttons. So let's say I press the button for type 1 it will show the annotation that are type 1 and when I pressed the button for type 2 it will show the annotation that are type 2 and so on...

func addAttractionPins() {
    let filePath = NSBundle.mainBundle().pathForResource("Attractions", ofType: "plist")
    let attractions = NSArray(contentsOfFile: filePath!)
    for attraction in attractions! {
        let point = CGPointFromString(attraction["location"] as! String)
        let coordinate = CLLocationCoordinate2DMake(CLLocationDegrees(point.x), CLLocationDegrees(point.y))
        let title = attraction["name"] as! String
        let typeRawValue = (attraction["type"] as! String).toInt()!
        let type = AttractionType(rawValue: typeRawValue)!
        let subtitle = attraction["subtitle"] as! String
        let annotation = AttractionAnnotation(coordinate: coordinate, title: title, subtitle: subtitle, type: type)
        mapView.addAnnotation(annotation)
    }
}
Mark Maraya
  • 225
  • 2
  • 9
  • What error are you getting? – brduca Jul 14 '15 at 09:19
  • I don't have an error. I only have one button to show all the annotation. What I want is to have multiple button for each type of annotation so I can filter the annotation by type and not to show them all. – Mark Maraya Jul 14 '15 at 09:37
  • You'll need to create this buttons dynamically and put it in your view. And bind the "tap" action. Here there is an example: http://stackoverflow.com/questions/24030348/how-to-create-a-button-programmatically. – brduca Jul 14 '15 at 15:08

0 Answers0