Turf.js圆形多边形坐标问题

时间:2018-01-22 12:54:25

标签: node.js polygon turfjs

图书馆http://turfjs.org/

平台使用:Node.js v8.9.4

草坪版:来自npm的最新版本 - @ turf / turf

代码:

var center = [20.659698486328125, -103.349609375];
var options = { steps: 5, units: 'kilometers', options: {} };
var radius = 1;
var polygon = turf.circle(center, radius, options);

我收到的多边形

[ [ [ 20.659698486328125, -76.65938382863723 ],
[ 20.663518747226156, -76.65934049531025 ],
[ 20.66730214442299, -76.65921091347738 ],
[ 20.655878225430094, -76.65934049531025 ],
[ 20.659698486328125, -76.65938382863723 ] ] ]

问题:

多边形坐标错误,纬度正确。然而,经度完全不同。

尝试使用这个库的每个和所有东西,仍然坐标错误,在完全不同的区域创建多边形。

1 个答案:

答案 0 :(得分:0)

尝试在调用fruit Apple Newyork fruit Apple California fruit Mango Newyork fruit Mango California fruit Mango Boston fruit Grapes Boston flowers roses Newyork flowers roses California

时交换中心的经度/纬度

turf.circle
var center_orig = [20.659698486328125, -103.349609375];
var center = [-103.349609375, 20.659698486328125];
var options = {
  steps: 5,
  units: 'kilometers',
  options: {}
};
var radius = 1;
var polygon = turf.circle(center, radius, options);

var map = L.map('mapid').setView(center_orig, 13);

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png').addTo(map);

L.geoJSON(polygon, {
  style: function(feature) {
    return {
      color: "red"
    };
  }
}).addTo(map);
#mapid {
  height: 264px;
}