Skip to content

Commit

Permalink
[GLJS-1149] Fixed feature state updates issues (internal-2101)
Browse files Browse the repository at this point in the history
  • Loading branch information
underoot committed Jan 14, 2025
1 parent 689cd0a commit b1f0021
Show file tree
Hide file tree
Showing 7 changed files with 182 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/source/tile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ class Tile {
// Buckets are grouped by common source-layer
const sourceLayerId = bucketLayer['sourceLayer'] || '_geojsonTileLayer';
const sourceLayer = vtLayers[sourceLayerId];
const sourceCache = painter.style.getSourceCache(bucketLayer.source, bucketLayer.scope);
const sourceCache = painter.style.getLayerSourceCache(bucketLayer);

let sourceLayerStates: FeatureStates = {};
if (sourceCache) {
Expand All @@ -639,7 +639,8 @@ class Tile {
const imagePositions: SpritePositions = (this.imageAtlas && this.imageAtlas.patternPositions) || {};
const withStateUpdates = Object.keys(sourceLayerStates).length > 0 && !isBrightnessChanged;
const layers = withStateUpdates ? bucket.stateDependentLayers : bucket.layers;
if ((withStateUpdates && bucket.stateDependentLayers.length !== 0) || isBrightnessChanged) {
const updatesWithoutStateDependentLayers = withStateUpdates && !bucket.stateDependentLayers.length;
if (!updatesWithoutStateDependentLayers || isBrightnessChanged) {
bucket.update(sourceLayerStates, sourceLayer, availableImages, imagePositions, layers, isBrightnessChanged, brightness);
}
if (bucket instanceof LineBucket || bucket instanceof FillBucket) {
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"version": 8,
"metadata": {
"test": {
"width": 16,
"height": 16,
"operations": [
["setFeatureState", {"source": "geojson", "id": 0}, {"hover": true}],
["wait"],
["removeFeatureState", {"source": "geojson", "id": 0}]
]
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 0,
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
]
}
}
},
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"paint": {
"text-opacity": [
"case",
["boolean", ["feature-state", "hover"], false],
1,
0.1
]
},
"layout": {
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-field": "0"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": 8,
"metadata": {
"test": {
"width": 16,
"height": 16,
"operations": [
["setFeatureState", {"source": "geojson", "id": 0}, {"hover": true}],
["wait"],
["removeFeatureState", {"source": "geojson", "id": 0}],
["wait"],
["setFeatureState", {"source": "geojson", "id": 0}, {"hover": true}],
["wait"]
]
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 0,
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
]
}
}
},
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"paint": {
"text-opacity": [
"case",
["boolean", ["feature-state", "hover"], false],
1,
0.1
]
},
"layout": {
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-field": "0"
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"version": 8,
"metadata": {
"test": {
"width": 16,
"height": 16,
"operations": [
["setFeatureState", {"source": "geojson", "id": 0}, {"hover": true}],
["wait"]
]
}
},
"glyphs": "local://glyphs/{fontstack}/{range}.pbf",
"sources": {
"geojson": {
"type": "geojson",
"data": {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 0,
"properties": {},
"geometry": {
"type": "Point",
"coordinates": [
0,
0
]
}
}
]
}
}
},
"layers": [
{
"id": "symbol",
"type": "symbol",
"source": "geojson",
"paint": {
"text-opacity": [
"case",
["boolean", ["feature-state", "hover"], false],
1,
0.1
]
},
"layout": {
"text-font": [
"Open Sans Semibold",
"Arial Unicode MS Bold"
],
"text-field": "0"
}
}
]
}

0 comments on commit b1f0021

Please sign in to comment.