G
G
German Jet2018-06-19 16:43:21
leaflet
German Jet, 2018-06-19 16:43:21

How to fix onmouseover over a separate road in Leaflet.js?

Hello!
The map has a layer of roads

var roads_layer = L.geoJson.ajax('http://192.168.5.155:8000/roads.geojson', {
}).addTo(mymap);

I need to change the style of the road when hovering over the road and show the popup.
Like this if I do
roads_layer.on('mouseover', function(e) {
    this.setStyle({
        color: 'orange'
     });
});
changes the appearance of the entire layer. How to catch a separate road when hovering the mouse?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Moskus, 2018-06-19
@GeraJet

Similar to https://leafletjs.com/examples/choropleth/ (here for polygons)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question