I'm trying to display data from another file such as a csv into a GeoJSON popup window. So far I know I can match the data using a nested for loop with a common id between the two files, but I'm wondering if it's even possible to display this data in the GeoJSON popup window. This is all done with a leaflet map as well.

My reason for displaying data from another file is that it needs to be updated frequently which is easier to do on a csv.


Short answer: yes.

Better answer: I think you should get your process that's writing the CSV to write JSON, if not GeoJSON. That will be easier.

If you do keep your attributes and GeoJSON separate, I'd look at putting the loading of the CSV and attributes in an 'oneachfeature' function, like in this example:

function onEachFeature(feature, layer) {
    // does this feature have a property named popupContent?
    if (feature.properties && feature.properties.popupContent) {

var geojsonFeature = {
    "type": "Feature",
    "properties": {
        "name": "Coors Field",
        "amenity": "Baseball Stadium",
        "popupContent": "This is where the Rockies play!"
    "geometry": {
        "type": "Point",
        "coordinates": [-104.99404, 39.75621]

L.geoJson(geojsonFeature, {
    onEachFeature: onEachFeature
  • Thanks. I'm looking into a library called "papaparse" which writes CSV to JSON – pnear Sep 8 '15 at 22:20
  • What language are you using? Python does it really simply. – Alex Leith Sep 8 '15 at 22:43
  • I'm using html to call the Papa.parse, which is a javascript library. The goal of using the "Papa.parse" library is to display csv data in the popup boxes for a number of Leaflet markers – pnear Sep 9 '15 at 3:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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