Ios 使用Mapbox搜索位置

Ios 使用Mapbox搜索位置,ios,swift,mapbox,Ios,Swift,Mapbox,我试图获取所选搜索地点的坐标,以便在地图上显示该地点,我设法做到了这一点并获取了坐标,但当我选择它时,它并没有按照我的意愿显示地图上的位置 这就是我所做的 func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { let place = self.searchedPlaces.object(at: indexPath.row) as! structName l

我试图获取所选搜索地点的坐标,以便在地图上显示该地点,我设法做到了这一点并获取了坐标,但当我选择它时,它并没有按照我的意愿显示地图上的位置 这就是我所做的

  func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        let place = self.searchedPlaces.object(at: indexPath.row) as! structName
        let coord = CLLocationCoordinate2D.init(latitude: place.geometry.coordinates[1], longitude: place.geometry.coordinates[0])
    
        let placeAnnototaion = MGLPointAnnotation()
        placeAnnototaion.coordinate = coord
        self.MapView?.addAnnotation(placeAnnototaion)
    }

欢迎来到Stackoverflow。到目前为止,您尝试了哪些调试步骤?你试过检查你的
coord
对象了吗?如果不是0,0,谢谢。当我检查coord对象时,它实际上会打印选定位置的long和lat。但是没有出现在地图上@GlennAny您的视口是否可能不包含注释?如果注释坐标不在视口中,则在您调用
addAnnotation
时,它不一定会自动调整地图视口。我实际上尝试了这个方法,但没有成功,或者创建了初始注释以用于当前位置,然后调用removeAnnotations func func tableView(uTableView:UITableView,didSelectRowatIndeXPath:indexPath){…MapView?.removeAnnotations((MapView?.annotations)!)@Rafaelalmedai不明白,你到底尝试了什么?欢迎来到Stackoverflow。到目前为止你尝试了哪些调试步骤?你是否尝试过检查你的
coord
对象,如果它不是0,0?谢谢。当我检查coord对象时,它实际上会打印所选位置的长度和纬度。但不会出现在地图上@GlennAny chance y我们的视口不包含注释?如果注释坐标不在视口中,则在您调用
addAnnotation
时,它不一定会自动调整地图视口。我实际上尝试了这个方法,但它不起作用,或者为使用的当前位置创建初始注释,然后调用removeAnnotations functableView(uTableView:UITableView,didSelectRowAt indexPath:indexPath){…MapView?.removeAnnotations((MapView?.annotations)!)}@RafaelalMedai我不明白,你到底尝试了什么?