Skip to content

Support to Mapbox Traffic v1 #1404

Answered by LucasBSC
LucasBSC asked this question in Q&A
Discussion options

You must be logged in to vote

Update on this

Managed to get it working with the following sample code if it can help someone:

const layerStyle = {
    id: 'traffic',
    type: 'line',
    source: 'mapbox-traffic',
    'source-layer': 'traffic',
};

  <ReactMapGL
        {...viewport}
        width="100%"
        height="100%"
        style={cssStyle}
        onClick={handleMapClick}
        ref={mapRef as any}
        mapStyle={mapStyle}
        onViewportChange={onViewportChange}
        mapboxApiAccessToken={process.env.REACT_APP_MAPBOX_API_KEY!}
      >
        <Source
          type="vector"
          url="mapbox://mapbox.mapbox-traffic-v1"
          id="mapbox-traffic"
        >
          <Layer
            {...l…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by LucasBSC
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant