我没有正确测试这个代码。但是应该给你一些关于如何解决上述问题的想法

var json = {

"type": "FeatureCollection",

"features": [

{

"type": "Feature",

"properties": {},

"geometry": {

"type": "Polygon",

"coordinates": [

[

[

-37.880859375,

78.81903553711727

],

[

-42.01171875,

78.31385955743478

],

[

-37.6171875,

78.06198918665974

],

[

-37.880859375,

78.81903553711727

]

]

]

}

},

{

"type": "Feature",

"properties": {},

"geometry": {

"type": "Polygon",

"coordinates": [

[

[

-37.6171875,

78.07107600956168

],

[

-35.48583984375,

78.42019327591201

],

[

-37.880859375,

78.81903553711727

],

[

-37.6171875,

78.07107600956168

]

]

]

}

}

]

}

$(document).ready(function(){

var counter = 1;

json.features.forEach(function(feature){

var data = {type: json.type, features: [feature]}

var newJson = JSON.stringify(data);

var blob = new Blob([newJson], {type: "application/json"});

var url = URL.createObjectURL(blob);

var a = document.createElement('a');

a.download = "feature_" + counter + ".json";

a.href = url;

a.textContent = "Download feature_" + counter + ".json";

counter++;

document.getElementById('feature').appendChild(a);

document.getElementById('feature').appendChild(document.createElement('br'));

});

});;

^{pr2}$;和13;

GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 3 个月前
8c391e04 6 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐