Turbo87 / leaflet-sidebar

A responsive sidebar for Leaflet maps
http://turbo87.github.io/leaflet-sidebar/examples/
MIT License
487 stars 157 forks source link

Leaflet 1.1.0. Geojson layer. 'Sidebar will be hidden' #49

Closed mykolakozyr closed 3 years ago

mykolakozyr commented 7 years ago

I'm using Leaflet 1.1.0 and want to toggle sidebar while clicking on features from .geojson layer. I currently work with polygon objects. open sidebar (demo version):

         function openSidebar(e) {
            sidebar.toggle();
        }

defining OnEachFeature:

        function onEachFeature(feature, layer) {
            layer.on({
                mouseover: highlightFeature,
                mouseout: resetHighlight,
                click: openSidebar
            });
        } 

open .geojson:

        var otgLayer = L.geoJson(otg, {
            style: regStyle,
            onEachFeature: onEachFeature,
        }).addTo(map)

While clicking on feature, there is the following in the console:

Sidebar will be visible. Sidebar will be hidden.

The sidebar works fine with Leaflet 0.7 when it is a .geosjon polygon The sidebar works fine with Leaflet 1.1.0 when it is a marker

mykolakozyr commented 7 years ago

the 'hide' function for .geojson layer raises by this part:

        map.on('click', function () {
            sidebar.hide();
        })
mykolakozyr commented 7 years ago

In my project i "fixed" by adding (below others) not existing function to the openSidebar(e) function. However, it seems like a bug.

milas991 commented 5 years ago

Did anybody fix this?

zedd45 commented 5 years ago

@mykolakozyr would you provide a code sample for what you meant by "adding 'not existing function' to openSidebar(e)?

zedd45 commented 3 years ago

I'm closing this for now. @mykolakozyr please feel free to share a sample of the code you used to fix this, and we can explore the issue as well as a potential fix.

Thanks!