cvalenzuela / Mappa

A canvas wrapper for Maps 🗺 🌍
https://mappa.js.org
360 stars 104 forks source link

how to display geojson polygons #15

Open mikima opened 6 years ago

mikima commented 6 years ago

I'm trying to load a geoJson containing several features (polygons and multi polygons) with data attached.

I't not clear to me, however, how to display them using mappa.

the API documentation explains how to load them but not how to display them.

Also, i have issue loading the geojson itself. When I try to laod polygons i get this error:

Uncaught (in promise) TypeError: Cannot read property 'type' of null

at i (mappa.js:463)

at mappa.js:482

at Array.forEach (<anonymous>)

at e.default (mappa.js:481)

at o.value (mappa.js:271)

Could you provide a simple example?

thanks

cvalenzuela commented 6 years ago

Here is an example of how to load a geoJSON file:

https://github.com/cvalenzuela/Mappa/tree/707158f19fee84195455b46f71057848b3f24c2a#complete-example-4

It was on a previous version, I removed it and then forgot to add it to the new website. Happy to work on a PR if you want to add it back again

mikima commented 6 years ago

Thanks!

mikima commented 6 years ago

Tried to play with it a little bit. But I don't understand what the advantage is in using myMap.geoJSON instead of just cycling through the JSON file itself. Is there something i'm missing?

cvalenzuela commented 6 years ago

It's a super simple wrapper around geoJSON file, just for the convenience of skipping some parts of the original file

mikima commented 6 years ago

i see. it's a pity yo loose access to the linked data. would be nice to have buil-in functions that directly create graphic items.

cvalenzuela commented 6 years ago

open to contributions! happy to help add this functionality