-
Notifications
You must be signed in to change notification settings - Fork 120
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
Is that possible to load a shapefile (zip) from an api ? #61
Comments
ToHold, "new L.Shapefile('myurl')" syntax works fine for me. HOWEVER, it seems picky with a requirement that your url path end with a ".zip", which is not self-evident. |
Thanks for you answer, But I've found a way to do what I wanted :).
See I've just added a parameter named "headers" at these function :
|
And for downloading a zip from api, I've used Symfony Headers, and Lexik JWT Token. |
And so I do not use leaflet.shapefile, but shp.js and L.geoJSON from leaflet. |
you can use ArrayBuffer. there is a mistake in leaflet.shpfile.js (line 44),you should change then you can use: fetch("http://exmaple.com/1")
.then(resp => resp.arrayBuffer())
.then(data => {
let layer = new L.Shapefile(data, {
isArrayBuffer:true
});
layer.addTo(map);
layer.once("data:loaded", function() {
map.fitBounds(layer.getBounds());
});
}); |
Hello ! First, thanks for this awesome project.
I'm currently developping an app that use leaflet and shapefile. But I'm also using an api that authenticate users with a JWT. Each users have some shapefile to load, so I would need to add authentication headers to "new L.Shapefile()".
Is that possible ? If yes how could I do it ?
The text was updated successfully, but these errors were encountered: