Adding a table around the pop-up information in Leaflet -
i want create table around pop-up information in leaflet. using bootstrap mark-up. tried following code didn't work:
oneachfeature: function (feature, layer) { layer.on({ click: function showresultsindiv() { var d= document.getelementbyid('tab4'); d.innerhtml = "<table>" "<tbody>" "<tr>" "<th scope="row"><h3>" + feature.properties.name + "</h3></th>" "</tr>" "<tr>" "<th scope="row">" "</th>" "</tr>" "<tr>" "<th scope="row">id</th>" "<td>" + feature.properties.id + "</td>" "</tr>" "<tr>" "<th scope="row">x</th>" "<td>" + feature.properties.x + "</td>" "</tr>" "<tr>" "<th scope="row">y</th>" "<td>" + feature.properties.y + "</td>" "</tr>" "<tr>" "<th scope="row">keten</th>" "<td>" + feature.properties.keten + "</td>" "</tr>" "<tr>" "<th scope="row">naam</th>" "<td>" + feature.properties.name + "</td>" "</tr>" "</tbody>" "</table>"; } }); } }).addto(map);
this want:
this code work doesn't give me table mark-up:
d.innerhtml = "<h3>" + feature.properties.name + "</h3> id:" + feature.properties.id + "<br> x-as:" + feature.properties.x + "<br> y-as:" + feature.properties.y + "<br> keten:" + feature.properties.keten + "<br> naam:" + feature.properties.name; $('.nav-tabs a[href="#tab4"]').tab('show');
you have 2 problems:
the strings not being concatenated. if going split strings in way in js, use
+
operator dangling @ end of every line, i.e.:d.innerhtml = "<table>" + "<tbody>" + "<tr>" + // etc
by default, tables in html don't have borders. either assign css class it, or use inline css in
<table>
tag.
Comments
Post a Comment