Giter VIP home page Giter VIP logo

Comments (4)

nickpeihl avatar nickpeihl commented on July 28, 2024

Thanks for your suggestion. I'm not opposed to the idea of adding the sidebar to the map container instead of the body. But I wasn't able to get your method to work in a quick trial. Additionally, I think your method would also require us to pass in the id of the map div which might not always be 'map'.

I think the best way forward is to refactor the code to be similar to how other Leaflet controls are add to the map. I'd be happy to review a pull request if you are willing to.

from leaflet-sidebar-v2.

christophfriedrich avatar christophfriedrich commented on July 28, 2024

I made a minimal version where my method works.

I don't really understand how it's done in your link - where is the container added to any element?!

You're right that the map div id could be something other than 'map'. I'd suggest: Leave line 33 as it is (so that the sidebar is created outside at first) and modify the addTo method so that it moves the sidebar HTML element inside the map specified there (that would be intuitive imo).

A problem that arises then: Click events on the map are also emitted when the user clicks on the sidebar, which I think is not desirable.

from leaflet-sidebar-v2.

nickpeihl avatar nickpeihl commented on July 28, 2024

Yes, I agree. Modifying the addTo method is probably the best option. Perhaps the other Leaflet controls might give a clue on how to avoid map click events?

from leaflet-sidebar-v2.

noerw avatar noerw commented on July 28, 2024

The reason for the current implementation is to support the static definition of panes in HTML while allowing modification through the sidebar API.

Leaflet controls store their container within the map div, but the DOM insertion is handled by Leaflet's plugin API itself.
In general the inner content of the leaflet map div should not be manually touched.

This leaves the option to move the childNodes of a static div.sidebar into the container that will be passed to Leaflet.
I will try this and see if it works

from leaflet-sidebar-v2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.