You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I still have issue with react-map-gl to update the Source dynamically. It may be super silly but I can't figure out whats wrong with this approach. Let's say I have multiple "tilesets" that are referenced by an id named tileName
Expected Behavior
No response
Steps to Reproduce
const sprayedLayer = {
id: `sprayed-layer-${props.tileName}`, // Add id that's unique per map
type: 'fill',
source: `sprayed-tiles-${props.tileName}`,
'source-layer': getSourceLayerId(),
paint: {
'fill-color': [
'interpolate',
['linear'],
['get', 'ratio'],
0, '#30dc30', // Green at low values
0.5, '#FFFF00', // Yellow at medium values
1, '#e60b0b' // Red at high values
],
'fill-opacity': fillOpacity
}
};
<Map
{...viewport}
style={{width: '100%', height: '100%'}}
mapStyle="mapbox://styles/mapbox/satellite-streets-v11"
mapboxAccessToken={process.env.REACT_APP_MAPBOX_TOKEN}
>
<Source
key={`source-${props.tileName}`}
id={`sprayed-tiles-${props.tileName}`} // Add id that's unique per map
type="vector"
tiles={[`${process.env.REACT_APP_TILE_SERVER_HOST}/data/${props.tileName}/{z}/{x}/{y}.pbf`]}
minzoom={0}
maxzoom={12}
>
<Layer key={`layer-${props.tileName}`}
{...sprayedLayer} />
</Source>
<ScaleControl/>
</Map>
I also want to dynamically add lines between markers. Markers can be added dynamically, as data changes, but changing the lines causes the error sourceID has changed. I even tried unmounting the map first manually.
Description
Hi.
I still have issue with react-map-gl to update the Source dynamically. It may be super silly but I can't figure out whats wrong with this approach. Let's say I have multiple "tilesets" that are referenced by an id named
tileName
Expected Behavior
No response
Steps to Reproduce
Environment
Logs
No response
The text was updated successfully, but these errors were encountered: