ios - Flag Annotation overlap and interchange to each other -
i facing problem show multiple annotation on mkmapview
. question that, have 3 type annotation as(select_starflag
, simple_flag
, currentlocation_flag
). flag show on map there interchange position between them, when scroll map, flag overlap each other. using following code
func mapview(mapview: mkmapview!, viewforannotation annotation: mkannotation!) -> mkannotationview! { if (annotation.iskindofclass(mkuserlocation)) { //if annotation not mkpointannotation (eg. mkuserlocation), //return nil map view draws"blue dot" standard user location return nil } if (annotation.iskindofclass(mkpointannotation)){ let reuseid = "test" var anview = mapview.dequeuereusableannotationviewwithidentifier(reuseid) mkannotationview! if (anview == nil) { anview = mkannotationview(annotation: annotation, reuseidentifier: reuseid) anview.canshowcallout = true var data = double(annotation.coordinate.latitude) var data1 = double(annotation.coordinate.longitude) var flag = bool(false) geodata in ysdatabasegeolocationarray{ var geolocationlat = double() var geolocationlong = double() geolocationlat = double(geodata.objectatindex(0) nsnumber) geolocationlong = double(geodata.objectatindex(1) nsnumber) if data == geolocationlat && data1 == geolocationlong { println(geolocationlat) println(geolocationlong) flag = true break } } if flag { anview.image = uiimage(named:"select_starflag") } else if data == double(yslatitude) && data1 == double(yslongitude){ if ysvalueflag != false{ anview.image = uiimage(named:"currentlocation_flag") }else { anview.image = uiimage(named:"simple_flag") } } else { anview.image = uiimage(named:"simple_flag") } } else { //we re-using view, update annotation reference.. anview.canshowcallout = true anview.annotation = annotation } return anview } return nil }
Comments
Post a Comment