Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show and hide osmbuildings objects #108

Open
rollinstar opened this issue Sep 19, 2017 · 2 comments
Open

How to show and hide osmbuildings objects #108

rollinstar opened this issue Sep 19, 2017 · 2 comments

Comments

@rollinstar
Copy link

rollinstar commented Sep 19, 2017

Hi,
Thank you for providing a wonderful project like this!
I'm developing a map using OSMBuildings, leaflet, and geojson.
But, I faced a problem.
My client want that OSMBuildings be toggled (on and off buildings) when they would like to see base maps.
Firstly, I used a function(onRemove()) for clearing a OSMBuilding objects and removed OSMBuildings objects.
Then, when I called a function(set()) for loading objects again, it did not operate.
So, I declared a new OSMBuildings object again, and I could render the OSMBuildings objects.
However, z-index of the OSMBuilding's instance changed to last z-index of leaflet map.
How can I toggle the OSMBuilding's objects which is already rendered without changing z-index?
Can you help me to solve this problem?

  • Actually, my English skill is not good so some sentences may be grammatically wrong. If you cannot understand my question, leave a comment please.
@kekscom
Copy link
Owner

kekscom commented Sep 20, 2017

Could you try to use Leaflets layer control?

var layers = {
    "buildings": osmb
};
L.control.layers(layers).addTo(map);

It should also allow to remove layers.
See: http://leafletjs.com/examples/layers-control/

@rollinstar
Copy link
Author

Thank you for your advice!
But this way still cannot solve problem that z-index of each layer is changed when layers are toggled.
My client want that particular layer is shown upper than OSMBuildings objects.
However, I think that this problem should be solved by leaflet, so I will try to find a way using leaflet library myself.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants