Leaflet path: how can I set a css class?

后端 未结 6 1448
一个人的身影
一个人的身影 2021-01-07 23:13

Well the title says it all but here is some code so you see what i mean.

function eachFeature(feature, layer) {
     layer.on({
         mouseover: highlight         


        
6条回答
  •  [愿得一人]
    2021-01-07 23:48

    You can either add a "className" attribute to your style object, or add the class later like this:

    function eachFeature(feature, layer) {
         layer.on({
             mouseover: highlightFeature,
             mouseout: resetHighlight,
         });
    }
    geojson = L.geoJson(geojson_raw, { style: style, onEachFeature: eachFeature });
    geojson.setStyle({'className': 'map-path'}); //will add the required class
    geojson.addTo(map);
    

提交回复
热议问题