0

I have a leaflet map that reload page and map view depending on a drop-down list. I have many layers in it and I'd like to keep selected layers as selected when the page reload after clicking on an item in the drop-down list.

I hope it's clear enough.

1
  • if you mean that a user's selection is 'saved' on page reload, you could use cookies – toms Jun 10 '15 at 14:24
0

Depending on your app and your browser requirements, you can use one of these methods:

  • Store selected layers in the browser, like session storage (https://developer.mozilla.org/en/docs/Web/API/Window/sessionStorage); doesn't work in all browsers
  • Store the information in the URL hash - nice if you want users to be able to share links with each other and get to the same state, works in all browsers (an example here: http://cykelbanor.se/ - check the URL changing when you switch layers etc.)
  • Store it in a cookie; should also work in all browsers
  • Store it on the server

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.