Using metadata from Mapbox Vector Tile layer for interaction and styling

Hi everyone!

I am using Plotly to plot an interactive map. I specify a Mapbox Vector Tile (MVT) as a source for a layer in my map (see code below). The geometrical data from the layer is plotted correctly. I know, however, that the source MVT includes extra metadata aside from the geometry of the individual entities which I would like to access for further interaction (click or hover) / styling differences (e.g. have different color for different value of specific feature in the metadata).

Can metadata from MVT layer be accessed and used for a Dash Application?

fig.update_layout(
    mapbox=go.layout.Mapbox(
        # ...,
        layers=[
            {
                  "below": 'traces',
                  "sourcetype": "vector",
                  "source": ["https://openinframap.org/tiles/{z}/{x}/{y}.pbf"],
                  "sourcelayer": "power_line",
                  "type": "line",  # geometry
                  "color": 'rgba(255, 0, 0, 0.75)',  # styling
            }
        ]
      # ...,
   )

Similar question from the forum: https://community.plotly.com/t/interact-with-mapbox-vector-tile-mvt-entities-within-choroplethmapbox/52131

1 Like