mapbox / geobuf

A compact binary encoding for geographic data.
ISC License
978 stars 84 forks source link

Implementation guide. #58

Closed ConorCoakley closed 8 years ago

ConorCoakley commented 8 years ago

I'm wondering is there any example implementation guide for geobuf? Anything that could guide someone like me (who's totally lost as to how to use it). Ideally some type of leaflet/mapbox related implementation spec would be great.

I understand you need to first encode your geojson file. Then include your geobuf browser build in your leaflet file.

For leaflet, I get that you can convert the encoded file to geojson in the browser like so:

var layer = L.geoJson( geobuf.decode( new Pbf(data) ) ).addTo(map);

However, I'm totally lost as to how to bring my pbf file into leaflet. How do I bring it in? Can I just include it in a similar way to how I would have for a normal geojson layer, i.e:

script src="json_County201602090.pbf"></script

And 'data' would be a variable inside my pbf file?

Can someone shed some light on how to properly use geobuf?

Apologies if my issue isn't that sophisticated. I'd really appreciate some kind of guide.

Thanks.

mourner commented 8 years ago

You can learn how to load binary data in a browser here https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/Sending_and_Receiving_Binary_Data