Мне не нужно смотреть ни на что, кроме того, что вы сказали. Вы ответили на свой вопрос.
аюсь интегрировать clusterKit для Mapbox и противодействую проблеме, где нижняя линия выходит как ноль.
if let cluster = annotation as? CKCluster, cluster.count > 1 { //nil
Эта строка находится внутри следующего метода:
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
Почему это происходит?Как я могу это исправить?Update2: Я считаю, что проблема не в этом, проблема в реализации. способ, который я реализовал, не кластеризован как следует, почему? я не знаю, любые предложения были бы хорошими. Но приведение к нулю, потому что это не кластер и не кластер, потому что я не думаю, что кластер работает так, как должен.
Я реализовал все необходимые методы, указанные впроцесс настройки или, по крайней мере, я так думал.
Обновить:
Вот некоторый код, который может быть полезен:
var annotations = [CustomPointAnnotation]()
func setupCluster(annotations: [CustomPointAnnotation]) {
print("obj annotations", annotations)
let algorithm = CKNonHierarchicalDistanceBasedAlgorithm()
mapView1.clusterManager.algorithm = algorithm
mapView1.clusterManager.annotations = annotations
}
Другой код ...
@nonobjc func mapView(_ mapView: MGLMapView, regionDidChangeAnimated animated: Bool) {
print("Change ")
mapView.clusterManager.updateClustersIfNeeded()
}
И это полный метод, который вверху имеет код, который не работает:
func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation) {
print(annotation," ",(annotation as? CKCluster)?.count, " also: ",annotation as? CKCluster)
if let cluster = annotation as? CKCluster, cluster.count > 1 {
print("inside if the k=cluser functionaluty")
let edgePadding = UIEdgeInsets(top: 40, left: 20, bottom: 44, right: 20)
let camera = mapView.cameraThatFitsCluster(cluster, edgePadding: edgePadding)
mapView.setCamera(camera, animated: true)
}
//zoom into the taped on annotation:
for object in arrayOfLineInformationObjects {
print(object, "<-- w0w")
let objectPolyline = "\(object.polyline!)" //dangerous to have !
let annotationPolyline = "\(annotation)" // cud be something else so maybe dont make only annotation polyline but acc were also gonna have a checl tp see if it was a poly line or annotation that u clicked on somewhoe
print(objectPolyline, "<-- object poly flower road")
print(annotation, "<-- annotaiton poly flower road")
if annotationPolyline == objectPolyline {
print("success!!")
let cam2 = mapView.cameraThatFitsShape(object.polyline!, direction: 0.0, edgePadding: .init(top: 20, left: 30, bottom: 100, right: 30))
mapView.fly(to: cam2, withDuration: 0.25, completionHandler: nil)
mapView.deselectAnnotation(annotation, animated: false)
break //will this only break the for loop or does it stop the whole function run
} else if annotationPolyline == "\(object.arrayOfPointAnnotations![0])" || annotationPolyline == "\(object.arrayOfPointAnnotations![1])" {
print("YOU HAVE TAPPED ON THIS ANNOTATION!")
let cam = mapView.cameraThatFitsShape(object.polyline!, direction: 0.0, edgePadding: .init(top: 20, left: 30, bottom: 100, right: 30))
mapView.fly(to: cam, withDuration: 0.25, completionHandler: nil)
mapView.deselectAnnotation(annotation, animated: false)
}
print("yes?") //does not print if break occurs
}
print(" ")
print(annotation, "<--") //<MGLPolyline: 0x2825375a0; count = 445; bounds = { sw = {37.3, -122.2}, ne = {37.4, -122.0}}> <--
print(annotation.coordinate, "<--") //center point of polyLine
print(annotation.hash, "<--") //cud this be the 0x2345345.... of the polyLine // its not
print(" ")
}