8
Tôi muốn vượt qua một file GeoJSON để tự động tạo ra DataTable sử dụng javascript, tôi không thể xác định tên cột trong tập tin .. Tôi đã thử này ..thế nào để Pass mảng GeoJSON để DataTable dyanamically sử dụng javascript
My code đang như thế này,
<body>
<table id="example" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th>fC.type</th>
<th>f.type</th>
<th>f.prop</th>
<th>f.geom.type</th>
<th>geometry.coordinates.0</th>
<th>geometry.coordinates.1</th>
</tr>
</thead>
</table>
</body>
$(document).ready(function() {
$('#example').dataTable({
"ajax":"data/json_file.json",
"processing":true,
"columns": [
{ "mData": "type" },
{ "mData": "features.type" },
{ "mData": "features.properties" },
{ "mData": "geometry.type" },
{ "mData": "geometry.coordinates.0" },
{ "mData": "geometry.coordinates.1" }
]
});
});
và tập tin GeoJSON là
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"properties": {},
"geometry": {
"type": "LineString",
"coordinates": [
[
40.078125,
57.136239319177434
],
[
91.7578125,
58.99531118795094
]
]
}
}
]
}
My output is as shown in image
Tôi cố gắng này ,, tôi đã nhận ra lỗi, "Loại lỗi chưa gặp: Không thể đọc thuộc 'chiều dài' không xác định". – Priyanka