Friday, 15 March 2013

javascript - d3 and geojson with multiple features and id -



javascript - d3 and geojson with multiple features and id -

i'm having problems multiple features on json. wanted split putting in multiple features can differentiate id. whenever seek place in id property on features throw json null.

here's geojson made

{ "type": "featurecollection", "features": [ { "id": "1", type": "feature", "properties": { "adm1_code": "png-1252", "objectid_1": 999, "diss_me": 1252, "adm1_cod_1": "png-1252", "iso_3166_2": "pg-", "wikipedia": null, "iso_a2": "pg", "adm0_sr": 3, "name": "milne bay", "name_alt": null, "name_local": null, "type": "province", "type_en": "province", "code_local": null, "code_hasc": "pg.mb", "note": null, "hasc_maybe": null, "region": null, "region_cod": null, "provnum_ne": 8, "gadm_level": 1, "check_me": 0, "scalerank": 6, "datarank": 8, "abbrev": null, "postal": "mb", "area_sqkm": 0.000000, "sameascity": -99, "labelrank": 6, "featurecla": "admin-1 scale rank", "name_len": 9, "mapcolor9": 3, "mapcolor13": 3, "fips": "pp03", "fips_alt": null, "woe_id": 2346583, "woe_label": "milne bay, pg, papua new guinea", "woe_name": "milne bay", "latitude": -11.581000, "longitude": 153.487000, "sov_a3": "png", "adm0_a3": "png", "adm0_label": 2, "admin": "papua new guinea", "geonunit": "papua new guinea", "gu_a3": "pnx", "gn_id": 2132895, "gn_name": "milne bay province", "gns_id": -2195635, "gns_name": "milne bay province", "gn_level": 1, "gn_region": null, "gn_a1_code": "pg.03", "region_sub": null, "sub_code": null, "gns_level": 1, "gns_lang":

http://jsfiddle.net/n2yz3/ (i used fiddle since text area limited 3k)

any advice on how assign id per shape appreciated! thanks

edit:

also, best way have multiple shapes selectable , have onclick event zoom in on spot selected?

your json invalid, missing quotes before the word type id 1

before:

{ "type": "featurecollection", "features": [ { "id": "1", type": "feature",

after:

{ "type": "featurecollection", "features": [ { "id": "1", "type": "feature",

javascript json d3.js geojson

No comments:

Post a Comment