Getting a Polygon from a Location
let polygons = location.geometry
let polygon = polygons.first
switch location.geometry?.type {
case "Point":
let point = location.geometry as? MPPoint
case "Polygon":
if let polygon = location.geometry as? MPPolygonGeometry, let perimeter = polygon.path {
for point in perimeter {
let lat = point.coordinate.latitude
let long = point.coordinate.longitude
}
}
case "MultiPolygon":
if let multiPolygon = location.geometry as? MPMultiPolygonGeometry {
// ...
}
default:
print("Unsupported geometry")
}Last updated
Was this helpful?