Advertise here

Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

MapKit taking over 30 seconds to load

jarvjarv Posts: 210Registered Users @ @

I am loading map pins based on lat/long from a JSON file but my 200+ pins take forever to load?!

My function <b>listPins()</b> is being called in the ViewDidLoad
func listPins(){
        ref = FIRDatabase.database().reference().child("venue-list").child("worthing-venue-list")
        ref.observe(FIRDataEventType.value, with: { (snapshot:FIRDataSnapshot) in
            for child in snapshot.children {
                if let snapDict = snapshot.value as? [String:AnyObject] {
                    for child in snapDict{
                        let shotKey = snapshot.children.nextObject() as! FIRDataSnapshot
                        if let name = child.value as? [String:AnyObject]{
                            if let latName = name["rsLat"] as? String,
                                let lonName = name["rsLong"] as? String {
                                let latitude = Double(latName) ?? 0.0
                                let longitude = Double(lonName) ?? 0.0
                                let theTitle = name["rsPubName"] as? String
                                let subTitle = name["rsTel"] as? String
                                let distancespan:CLLocationDegrees = 5000
                                let theLocations:CLLocationCoordinate2D = CLLocationCoordinate2DMake(latitude, longitude)
                                self.mapView.setRegion(MKCoordinateRegionMakeWithDistance(theLocations, distancespan, distancespan), animated: true)
                                let worthingClassPin = mapAnnotation(title: theTitle!, subtitle: subTitle!, coordinate: theLocations)
Sign In or Register to comment.