ProminentEdge / leaflet-measure-path

Show measurements on Leaflet paths

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

L.GeoJSON support

hellracer opened this issue · comments

Hi guys,

Any chances this could also be implemented on L.GeoJSON? thanks!

Hi! You should already be able to use this with a GeoJSON using the onEachFeature option to enable measurements:

var geoJsonLayer = L.geoJson(geoJson, {
    onEachFeature: function(feature, layer) {
        if (layer.showMeasurements) {
            layer.showMeasurements();
        }
    }
});

Haven't actually tried it, but should work. Give a shout if you encounter any trouble!

hi @perliedman I try your code for a L.geoJson but it display nothing (or I miss something).

Thanks for your input and your code too ;)

----- Edit ----

Just found the right way to do it:

var geoJsonLayer = L.geoJson(response, {showMeasurements: true}).addTo(map);