Geojson

Geojson

MonduizMonduiz Posts: 3Questions: 1Answers: 0

Hello,

I am new in the world of javascript so I apologize in advance for my basic understanding.
I'm turning the results of a project into a simple app using a map and I want to give access to the data, hence DataTables which looks fantastic compared to anything else. I have a quite large datasets and I have been trying to figure this out.

Can I use the same file I'm using for the rest of the app? Its a geojson structured like so and imported using link relation:

var Data =
{"type":"FeatureCollection","features":[
{"type":"Feature","properties":
{"OBJECTID":2,
"Shape_Leng":4.57546356,
"Shape_Area":0.04509886",
"AreaCode":5678,
"AreaName":"Area1",
etc.

Thanks for any insights!

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    You would need to render your data in the json format required by DataTables. There is an example in this thread: https://datatables.net/forums/discussion/22072/json-no-data-available-in-table
    and there are plenty of other relevant posts in the forum.

  • MonduizMonduiz Posts: 3Questions: 1Answers: 0

    Thank you, Tangerine. After reading more I realized DT is not going to read Geoson natively the same way everything else does. I will have to tweak the formatting as indicated in the very useful link you provided. I'm grateful for your reply!

  • allanallan Posts: 63,687Questions: 1Answers: 10,500 Site admin

    Can you show a full GeoJSON example? I don't see any reason why it wouldn't read it directly. You just need to tell DataTables what to show in each column using columns.data.

    Allan

  • MonduizMonduiz Posts: 3Questions: 1Answers: 0

    Hello allan, I will give this another go. I had to post-pone this component to advance the app. As for the structure, its very much like I have shown above. The columns.data information is helpful. I will also try to run the geojson through jsonlint to clean it. Hopefully, it should work after that. Thanks!

This discussion has been closed.