JSON File Data Popup

108 views
Skip to first unread message

Michael Schoelen

unread,
Oct 1, 2015, 3:26:03 PM10/1/15
to Leaflet
So I have a JSON file displayed on my leaflet webmap. I would like to have it so a popup will appear when a feature is clicked. Right now it is a polygon feature. How do I call up information from the JSON file (Syriashape.json) so it can be displayed? The fields I would like to display are called "Sheet_Num" and "Date"

Currently, this is what I have:

  // load GeoJSON from an external file
  $.getJSON("Syriashape.json",function(data){
    // add GeoJSON layer to the map once the file is loaded
    L.geoJson(data).addTo(map).bindPopup("Attributes Popup Here");
  });





ghybs

unread,
Oct 8, 2015, 1:40:09 AM10/8/15
to Leaflet
Hi,

Have you tried the `onEachFeature` option when creating your L.GeoJSON layer?
http://leafletjs.com/reference.html#geojson-oneachfeature

You can take example on what this guy shows: https://github.com/Leaflet/Leaflet.markercluster/issues/563

Hope this helps.
Reply all
Reply to author
Forward
0 new messages