无法 "stringify" geoJSON 数据
Cannot "stringify" geoJSON data
使用 Leaflet JavaScript 我正在尝试使用 Ajax link 直接从 GeoServer 中提取数据。为了将它很好地放在 DataTables table 中,我需要根据 DataTables 说明 JSON.stringify 它。我得到一个 "Circular structure"。还有其他方法吗?
这是我的代码:
通过Ajax
从地理服务器获取选定的特征
function handleJson(data) {
selectedFeature = L.geoJson(data, {
onEachFeature: function (feature, layer) {
},
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
radius: 5,
color: '#3006e8',
weight: 5,
opacity: 100,
fillOpacity: 100
});
}
});
selectedFeature.addTo(drawnItems);
现在这里是我理想地使用 JSON.stringify 来实现 datatables.net 一位非常乐于助人的人提供的这些结果......
http://live.datatables.net/sokitihe/3/edit
我认为 var selectedFeature 的数据 JSON.stringify 正确吗?我试过了,没用。
您可以使用以下方法将 GeoJSON LayerGroup 直接导出到 FeatureCollection 中:
selectedGeoJSON = selectedFeature.toGeoJSON();
然后你就可以用它做任何你想做的事,如果你愿意,可以将它字符串化。
JSON.stringify(selectedGeoJSON);
使用 Leaflet JavaScript 我正在尝试使用 Ajax link 直接从 GeoServer 中提取数据。为了将它很好地放在 DataTables table 中,我需要根据 DataTables 说明 JSON.stringify 它。我得到一个 "Circular structure"。还有其他方法吗?
这是我的代码:
通过Ajax
从地理服务器获取选定的特征function handleJson(data) {
selectedFeature = L.geoJson(data, {
onEachFeature: function (feature, layer) {
},
pointToLayer: function (feature, latlng) {
return L.circleMarker(latlng, {
radius: 5,
color: '#3006e8',
weight: 5,
opacity: 100,
fillOpacity: 100
});
}
});
selectedFeature.addTo(drawnItems);
现在这里是我理想地使用 JSON.stringify 来实现 datatables.net 一位非常乐于助人的人提供的这些结果......
http://live.datatables.net/sokitihe/3/edit
我认为 var selectedFeature 的数据 JSON.stringify 正确吗?我试过了,没用。
您可以使用以下方法将 GeoJSON LayerGroup 直接导出到 FeatureCollection 中:
selectedGeoJSON = selectedFeature.toGeoJSON();
然后你就可以用它做任何你想做的事,如果你愿意,可以将它字符串化。
JSON.stringify(selectedGeoJSON);