Skip to content

The annotation disappear suddenly, sometimes swap to other annotation...happen often #38

@vjerryv

Description

@vjerryv

https://www.youtube.com/watch?v=Ud-d4giz_4A

You can see the video, these are 2 red and 1 green annotation I want to show you.
when I drag them to off the screen, and drag them back, they may disappear or swap the other annotation. it happens very often.

My DB has about few hundred annotation. Is my implementation problem or the library bug?

` func removeAllPin(){
mapView_.removeAnnotations(pin_mcs_)
mapView_.removeAnnotations(pin_mcp_)
mapView_.removeAnnotations(pin_pcs_)
mapView_.removeAnnotations(pin_pcp_)
mapView_.removeAnnotations(pin_petrol_)
mapView_.removeAnnotations(pin_speedingCamera_)

    pin_mcs_.removeAll()
    pin_mcp_.removeAll()
    pin_pcs_.removeAll()
    pin_pcp_.removeAll()
    pin_petrol_.removeAll()
    pin_speedingCamera_.removeAll()
}

func addAllPin(){
    var tempArray:[MKAnnotation] = []
    if(toggle_pin_mcs_.selected){
        tempArray += pin_mcs_ as [MKAnnotation]
    }
    if(toggle_pin_mcp_.selected){
        tempArray += pin_mcp_ as [MKAnnotation]
    }
    if(toggle_pin_pcs_.selected){
        tempArray += pin_pcs_ as [MKAnnotation]
    }
    if(toggle_pin_pcp_.selected){
        tempArray += pin_pcp_ as [MKAnnotation]
    }
    if(toggle_pin_petrol_.selected){
        tempArray += pin_petrol_ as [MKAnnotation]
    }
    if(toggle_pin_speedingCamera_.selected){
        tempArray += pin_speedingCamera_ as [MKAnnotation]
    }

    mapView_.addClusteredAnnotations(tempArray)
}





func mapView(mapView: TSClusterMapView!, viewForClusterAnnotation annotation: MKAnnotation!) -> MKAnnotationView! {

    var view:MyClusterAnnotationView? = self.mapView_.dequeueReusableAnnotationViewWithIdentifier(NSStringFromClass(MyClusterAnnotationView.self).componentsSeparatedByString(".").last!) as? MyClusterAnnotationView
    if(view == nil){
        view = MyClusterAnnotationView(annotation: annotation, reuseIdentifier: NSStringFromClass(MyClusterAnnotationView.self).componentsSeparatedByString(".").last!)
    }

    return view;
}

func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {

    var view:MKAnnotationView?

    if (annotation is PinMcsAnnotation) {
        view = self.mapView_.dequeueReusableAnnotationViewWithIdentifier(NSStringFromClass(PinMcsAnnotation.self).componentsSeparatedByString(".").last!)
        if(view == nil){
            view = MKAnnotationView(annotation: annotation, reuseIdentifier: NSStringFromClass(PinMcsAnnotation.self).componentsSeparatedByString(".").last!)
        }
        view!.image = UIImage(named: "map_pin_mcs")
        view?.canShowCallout = false
        view?.centerOffset = CGPointMake(view!.centerOffset.x, -view!.frame.size.height/2)
    }
    else if (annotation is PinMcpAnnotation) {
        view = self.mapView_.dequeueReusableAnnotationViewWithIdentifier(NSStringFromClass(PinMcpAnnotation.self).componentsSeparatedByString(".").last!)
        if(view == nil){
            view = MKAnnotationView(annotation: annotation, reuseIdentifier: NSStringFromClass(PinMcpAnnotation.self).componentsSeparatedByString(".").last!)
        }
        view!.image = UIImage(named: "map_pin_mcp")
        view?.canShowCallout = false
        view?.centerOffset = CGPointMake(view!.centerOffset.x, -view!.frame.size.height/2)
    }
    else if (annotation is PinPcsAnnotation) {
        view = self.mapView_.dequeueReusableAnnotationViewWithIdentifier(NSStringFromClass(PinPcsAnnotation.self).componentsSeparatedByString(".").last!)
        if(view == nil){
            view = MKAnnotationView(annotation: annotation, reuseIdentifier: NSStringFromClass(PinPcsAnnotation.self).componentsSeparatedByString(".").last!)
        }
        view!.image = UIImage(named: "map_pin_pcs")
        view?.canShowCallout = false
        view?.centerOffset = CGPointMake(view!.centerOffset.x, -view!.frame.size.height/2)
    }
    else if (annotation is PinPcpAnnotation) {
        view = self.mapView_.dequeueReusableAnnotationViewWithIdentifier(NSStringFromClass(PinPcpAnnotation.self).componentsSeparatedByString(".").last!)
        if(view == nil){
            view = MKAnnotationView(annotation: annotation, reuseIdentifier: NSStringFromClass(PinPcpAnnotation.self).componentsSeparatedByString(".").last!)
        }
        view!.image = UIImage(named: "map_pin_pcp")
        view?.canShowCallout = false
        view?.centerOffset = CGPointMake(view!.centerOffset.x, -view!.frame.size.height/2)
    }
    else if (annotation is PinPetrolAnnotation) {
        view = self.mapView_.dequeueReusableAnnotationViewWithIdentifier(NSStringFromClass(PinPetrolAnnotation.self).componentsSeparatedByString(".").last!)
        if(view == nil){
            view = MKAnnotationView(annotation: annotation, reuseIdentifier: NSStringFromClass(PinPetrolAnnotation.self).componentsSeparatedByString(".").last!)
        }
        view!.image = UIImage(named: "map_pin_petrol")
        view?.canShowCallout = false
        view?.centerOffset = CGPointMake(view!.centerOffset.x, -view!.frame.size.height/2)
    }
    else if (annotation is PinSpeedingCameraAnnotation) {
        view = self.mapView_.dequeueReusableAnnotationViewWithIdentifier(NSStringFromClass(PinSpeedingCameraAnnotation.self).componentsSeparatedByString(".").last!)
        if(view == nil){
            view = MKAnnotationView(annotation: annotation, reuseIdentifier: NSStringFromClass(PinSpeedingCameraAnnotation.self).componentsSeparatedByString(".").last!)
        }
        view!.image = UIImage(named: "map_pin_speeding_camera")
        view?.canShowCallout = false
        view?.centerOffset = CGPointMake(view!.centerOffset.x, -view!.frame.size.height/2)
    }

    return view;
}



func mapView(mapView: TSClusterMapView!, shouldForceSplitClusterAnnotation clusterAnnotation: ADClusterAnnotation!) -> Bool {
    return true
}

func mapView(mapView: TSClusterMapView!, shouldRepositionAnnotations annotations: [ADClusterAnnotation]!, toAvoidClashAtCoordinate coordinate: CLLocationCoordinate2D) -> Bool {
    return true
}

`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions