Closed Spaxe closed 7 years ago
Can you reproduce this with a more minimal test case that doesn't involve a server?
I only get this problem while loading it from the client... so I'm not sure. Any suggestions on how I might be able to make the test smaller?
Don't load the JSON from the server, just hardcode it on the HTML page.
One HTML page test https://gist.github.com/Spaxe/f44a70e726b6eae13656f7ac7579de67
This version doesn't reproduce the bug I'm experiencing, unfortunately. Everything works.
I'm not sure where things got lost.
Looks like response.data
is not a buffer by the time you get it from the server. Maybe something to do with MIME types (you need to request the geobuf as binary). Anyway, not a geobuf issue.
Thanks @mourner for the hint!
Adding { responseType: 'arraybuffer' }
did indeed solve my problem. :)
Can we make the documentation a little clearer? I'll send in a PR shortly.
Minimal test case: https://gist.github.com/Spaxe/197ace389e4dc3ac286258e32ca0c0cc
The strange thing is that
geobuf2json
andjson2geobuf
converts it perfectly, so I don't really know what I'm missing.To run the test, run
node index.js
. npm dependencies aregeobuf
,pbf
.Then
index.html
needs to be served by something likehttp-server -p 8001
.