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

Figure out how to use vector tiles #9

Closed
kylebarron opened this issue Nov 22, 2019 · 4 comments
Closed

Figure out how to use vector tiles #9

kylebarron opened this issue Nov 22, 2019 · 4 comments

Comments

@kylebarron
Copy link
Member

100% should figure out how to use vector tiles. Testing

tippecanoe -zg -o wilderness.mbtiles --drop-densest-as-needed wilderness.geojson

on the wilderness boundaries takes the file size from 17MB to 2.7MB. That's an 85% drop!

Using mbview to inspect this in the browser, it's important to note that you can still get metadata out of the tiles!! I can hover over a wilderness area and see its attributes. So using vector tiles looks like an obvious improvement with no real drawback.

@kylebarron
Copy link
Member Author

@kylebarron
Copy link
Member Author

@kylebarron
Copy link
Member Author

This is it:

<MapboxGL.VectorSource
  id="nationalParkBoundaries"
  url="https://tiles.nst.guide/nationalpark/tile.json"
  onPress={event => console.log(event.nativeEvent.payload.properties)}
  ref={source => {
    this._vectorSource = source;
  }}
>
  <MapboxGL.FillLayer
    id="nationalParkFill"
    sourceLayerID="nationalpark"
    style={layerStyles.nationalParkFill}
    visibility="visible"
  />
</MapboxGL.VectorSource>

The key is that you also need the sourceLayerID. There can be many layers in a vector tile, and obviously you need to associate the FillLayer style with a specific layer.

I think with Tippecanoe, usually the layer name is the same as what the file name was. But if you can't figure it out, this tool will tell you the layer names.

@kylebarron
Copy link
Member Author

Fixed in 27a3ac8

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

1 participant