使用平台的:Node.js v8.9.4
Turf版本:来自npm -@草皮/草坪的最新版本
代码:
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 ] ] ]发行:
多边形坐标是错误的,纬度是正确的。然而,经度完全不同。
用这个库尝试了每一件事,仍然坐标是错误的,在完全不同的区域创建多边形。
发布于 2018-01-22 13:13:00
在调用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;
}<link href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" rel="stylesheet" />
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@turf/turf@5/turf.min.js"></script>
<div id="mapid"></div>
https://stackoverflow.com/questions/48382086
复制相似问题