How to draw GeoJSON in Apple Maps as overlay using Swift 3

Deadly 提交于 2019-12-03 16:27:39

In the first dictionary of features your coordinates key having 2D array, so you need to also add one more if let condition in your geometryObject.values for loop.

for obj in geometryObject.values {
    print(obj)
    if let type = obj as? String {
        typeData = type
    } 
    if let coordObj = obj as? [Double] {
        coord = Coordinates(latitude: coordObj[0], longitude: coordObj[1])
        coordData?.append(coord)
    }
    //Add one more if let condition
    if let coordObj = obj as? [[Double]] { 
        for coordinate in coordObj {
            let coord = Coordinates(latitude: coordinate[0], longitude: coordinate[1])
            coordData?.append(coord)
        }
    }
    geometries = Geometry(type: typeData, coordinates: coordData!)
}
let feature = Feature(type: type, properties: properties!, geometry: geometries!)
features.append(feature)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!