1
我想在運行時將其他屬性添加到topojson。我已經看過Choropleth的例子,但我不認爲有人操縱原始的json文件。如何以編程方式在運行時向topojson文件添加屬性?
什麼是做到這一點的最好方法是什麼?
JSON:
{ "type":"Topology",
"objects":{
"countries":{
"bbox":[ ... ],
"type":"GeometryCollection",
"geometries":[
{
"type":"Polygon",
"properties":{
"name":"Afghanistan",
"count": 30 // <------- Property I want to add.
},
"id":"AFG",
"arcs":[ ... ]
},
{
"type":"MultiPolygon",
"properties":{
"name":"Angola",
"count": 50 // <------- Property I want to add.
},
"id":"AGO",
"arcs":[ ... ]
} ...
}
的合併數組將是這個樣子:
[{ "Angola" : 50 }, { "Afganistan" : 30 }, ... ]