Question

I am working to resize the json file that I have automatically after reading json file. But I am getting errors.

$.getJSON("data/cities.json", function (data) {
        getData = topojson.feature(data, data.features);
        console.log( getData)
    });

Cities.json look like

{
 "type": "FeatureCollection",
 "features": [{
     "geometry": {
         "type": "MultiPolygon",
         "coordinates": [
             [
                 [
                     [-73.8283219965448, 40.8446061654002],
                     [-73.828397789942, 40.844583182304],
                     [-73.8285477331865, 40.8448132168025],
                     [-73.8284744943625, 40.8448401137412],
                     [-73.8283219965448, 40.8446061654002]
                 ]
             ]
         ]
     },
     "type": "Feature",
 , {
     "geometry": {
         "type": "MultiPolygon",
         "coordinates": [
             [
                 [
                     [-73.832361912256, 40.8488019205992],
                     [-73.832369554769, 40.8487286684528],
                     [-73.8327312374341, 40.8487518102579],
                     [-73.8327304815978, 40.8487590590352],
                     [-73.8327235953166, 40.8488250624279],
                     [-73.832361912256, 40.8488019205992]
                 ]
             ]
         ]
     },
     "type": "Feature"
 } 


}

How can I load json data using getJSON then pass it to topojson

Was it helpful?

Solution

GeoJSON and TopoJSON are two different formats. You cannot use TopoJSON functions to process GeoJSON. You need to convert the GeoJSON you have to TopoJSON (see the commandline reference) and then load that.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top