-
Notifications
You must be signed in to change notification settings - Fork 189
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
Problems with data:loaded #45
Comments
this downloads and adds all the layers before calling that event, try adding |
Adding allSchemes directly to the map appears to add all the markers, but so the following also works:
If you log the number of _layers of allSchemes before the delay it returns 75 and after the delay it says 263 which would imply that the 'data:loaded' is occurring before allSchemes is fully prepared. Additionally if the delay is reduced it gets to a point where the delay is not enough for this to occur. I'm reluctant to use this technique as a "fix" as this delay could well be network dependant. I will do some further tests when I get time. |
it's not going to be network dependent, the data is added to the layer once, most likely there is a delay in leaflet adding all of the layers somehow, what you can do is you can use the ajax loader directly L.Util.ajax(url).then(function (data){
// add layers here
}); |
Hi I'm using the plug-in to load GeoJSON data from a Drupal server into a leaflet map. The problem I appear to be having is with the on data:loaded event triggering before all of the data seems to have been made available.
The following is "almost" working but rather than the 200+ markers that should be present only the first 75 seem to be present when the data:loaded function is called. These 75 markers display correctly on the map in appropriate clusters.
If, using console.log() I output the number of layers in the allSchemes object or list the keys of the allSchemes._layers object the answer is always 75. However, if I log the object allSchemes._layer itself, then the object contains all 200+ entries I would expect. I presume that the console only populates the full _layers object to display the list of contents only when it is clicked on.
Looking at the keys given to each layer object in allSchemes._layers, there appears to be gap in the sequence after the first 75 before the 76th. (Often a gap of about 50 numbers). The remainder of the keys again run in sequence.
To confuse things further or maybe clarify things?, the map has a user interaction that allows you to filter the markers using code which effectively does the following. Here all of the 200+ markers are present and can be displayed correctly.
I can only presume that when the data:loaded event is triggered all the data has not been loaded or is available in the object.
Am I doing something wrong or is there anything I could do to correct this behaviour?
Thanks.
The text was updated successfully, but these errors were encountered: