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

have refresh clear layers directly before loading new #52

Open
mike16889 opened this issue Oct 28, 2017 · 1 comment
Open

have refresh clear layers directly before loading new #52

mike16889 opened this issue Oct 28, 2017 · 1 comment

Comments

@mike16889
Copy link

would it be possible to have the refresh feature on clear layers once the new data has been downloaded and about to be applied, maybe by use of the middleware function?

As it currently sits it clears the layer and a a second or more passes and the new one appears. if it was done after the data was loaded it should just be a flash and any new ones would seem to just appear.

I would write the code myself and contribute it but i am just learning javascript and even the simplest tasks at the moment are basically just trial and error for me.

@calvinmetcalf
Copy link
Owner

due to how it's set up where you can have multiple layers in there that's not so easy a task, you could manually load the data and then swap it out yourself like

var geojsonLayer = new L.GeoJSON.AJAX(your url);
// geojsonLayer.refresh()
L.Util.ajax(your url).then(function (data) {
  geojsonLayer.clearLayers();
  geojsonLayer.addData(data);
});

L.Util.ajax is what this uses behind the scenes and returns a promise

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