如何获取MGLPolygon
或任何MGLShape
的中心坐标?
var points = [
CLLocationCoordinate2D(latitude: 40.718379593199494, longitude: -74.00519371032715),
CLLocationCoordinate2D(latitude: 40.717273679029205, longitude: -74.00639533996582),
CLLocationCoordinate2D(latitude: 40.713435363794270, longitude: -73.99841308593750),
CLLocationCoordinate2D(latitude: 40.714150998671556, longitude: -73.99755477905273),
CLLocationCoordinate2D(latitude: 40.716037635568070, longitude: -73.99643898010254),
CLLocationCoordinate2D(latitude: 40.728201906826750, longitude: -73.99137496948242),
CLLocationCoordinate2D(latitude: 40.743810548166270, longitude: -73.97961616516113)]
let polygon = MGLPolygon(coordinates: &points, count: UInt(points.count))
map.addOverlay(polygon)
使用上面的代码我正在为polygon
和polyline
创建形状。