Skip to main content
10 events
when toggle format what by license comment
Jan 16, 2023 at 15:42 comment added Pfalbaum @BillChappell The tiles for OSM B&W in your example do not load, FYI.
Jan 17, 2019 at 21:26 comment added Laurent It works ! Thanks you !! I made a little modification to your line at the very end (remove () and add =) : hypeDocument.getElementById("Rectangle2").innerHTML = "test"+e.target.feature.properties.Titre
Jan 17, 2019 at 21:13 comment added Laurent Still no effect. Actually, it appears that I may already have a layer.on click function at the end of my geojson display : }).addTo(hypeDocument.map).on('click', markerOnClick);
Jan 17, 2019 at 20:59 comment added Bill Chappell Put this in your onEachFeature and test it. layer.on('click', function (e) { document.getElementById("Rectangle").innerHTML(e.target.feature.properties.Annee); }
Jan 17, 2019 at 20:48 comment added Laurent That's what I'm doing, Bill, thank you for all your good advice. But I'm afraid I'm terrible at coding. Your code is beautiful but with a different logic that the part of mine that works so far. I'd like to keep what I have and adapt your layer click to it.
Jan 17, 2019 at 20:41 comment added Bill Chappell Look at my example link, right clcik on the page and view source. The html and JS are all there. My GeoJSON file is here. gistechsolutions.com/leaflet/DEMO/baseball/BaseBallFinal.json is you save it as BaseBallFinal.json and toss it in the same folder as the html file, it should work. The" layer.on('click', function (e) {" method work for markers , polygons, and polyline features.
Jan 17, 2019 at 20:32 comment added Laurent Well, I'm not that good in JS. "Rectangle" is the the ID, yes. Should I put layerOnClick instead of markerOnClick ? How should my code look like ?
Jan 17, 2019 at 20:30 comment added Bill Chappell You had it firing on a marker click function, try using/putting the layer on click in the onEachFeature function.That gets the specific feature you clicked on and sends it's attributes. getElementById("Rectangle").innerHTM "Rectangle" is an HTML ID right? A div or span tag with that ID? It's not the feature.
Jan 17, 2019 at 20:22 comment added Laurent Thanks Bill ! I try to adapt your code but with no result so far.
Jan 17, 2019 at 18:21 history answered Bill Chappell CC BY-SA 4.0