0

I'm using leaflet to create a world map with geojson. Now I need to add some additional information as popup for each country but I'm not sure how should I proceed it. Been finding solution for hours.

  1. Should I modify geojson file to add 1 more field since it already listed coordinates of all the countries. Can I achieve this by php or js?
  2. Should I just store the information in SQL ("US" -> "US's text", "Canada" -> "Canada's text,...) & use switch case to compare string in onEachFeature function?
1
  • Easy way to add field, is open the GeoJSON file at geojson.io and add a field, You can even add values there and save the file. Then in Leaflet onEachFeature, just bindpopup to feature.properties.MyNewField. Aug 20, 2018 at 13:28

1 Answer 1

2

I recommend using QGIS to build your Leafletjs or OpenLayers map You install the QGIS2Web Plugin and run through the wizard https://github.com/tomchadwin/qgis2web/wiki

Then you have a fully functional map. You can then tweak the generated code. It even generates the styling and labeling! Very powerful and free.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.