2

I have a map Here based on leaflet JS and the layers are geojson. I would like to get a table at on another div when I click on each layers.

How would I be able to do that?

Thanks

  • A table to display properties for the selected feature? – doktoreas Oct 20 '14 at 7:02
4

You prepare an empty table with an id

<table id="properties"></table>

And you populate it with innerHTML property

for (var prop in properties) {
   if (properties.hasOwnProperty(prop)) { 
        document.getElementById("properties").innerHTML = document.getElementById("properties").innerHTML + "<tr><td>" + prop + "</td><td>" + properties[prop] + "</td></tr>";
   } 
}

See on this JSFiddle (it is done on mouseover, but you should be able to change it easily)

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.