swift geoJSON can not encode

84 Views Asked by At

I'm trying to get geoJSON:

import GeoJSON
import MapKit

let coordArray: [CLLocationCoordinate2D] = [CLLocationCoordinate2D(latitude: 77, longitude: 44), CLLocationCoordinate2D(latitude: 78, longitude: 45), CLLocationCoordinate2D(latitude: 79, longitude: 46)]

let way: GeoJSONLineString = GeoJSONLineString(coordinates: coordArray)

let features: GeoJSONFeatureCollection = GeoJSONFeatureCollection(dictionary: way.dictionaryRepresentation)
let json = try JSONEncoder().encode(features)

But i have error: Instance method 'encode' requires that 'GeoJSONFeatureCollection' conform to 'Encodable'

0

There are 0 best solutions below