MapBox [IOS]:如何获得MGLPolygon或MGLPolyline中心坐标

时间:2017-01-12 09:47:43

标签: mapbox

如何获取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)

使用上面的代码我正在为polygonpolyline创建形状。

0 个答案:

没有答案