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

Fix promoteId for line layers #9210

Merged
merged 3 commits into from
Jan 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/data/bucket/line_bucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class LineBucket implements Bucket {
const lineSortKey = this.layers[0].layout.get('line-sort-key');
const bucketFeatures = [];

for (const {feature, index, sourceLayerIndex} of features) {
for (const {feature, id, index, sourceLayerIndex} of features) {
if (!this.layers[0]._featureFilter(new EvaluationParameters(this.zoom), feature)) continue;

const geometry = loadGeometry(feature);
Expand All @@ -130,7 +130,7 @@ class LineBucket implements Bucket {
undefined;

const bucketFeature: BucketFeature = {
id: feature.id,
id,
properties: feature.properties,
type: feature.type,
sourceLayerIndex,
Expand Down
14 changes: 10 additions & 4 deletions src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@
"type": "string",
"doc": "Contains an attribution to be displayed when the map is shown to a user."
},
"promoteId": {
"type": "promoteId",
"doc": "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{<sourceLayer>: <propertyName>}`. If specified as a string for a vector tile source, the same property is used across all its source layers."
},
"*": {
"type": "*",
"doc": "Other keys to configure the data source."
Expand Down Expand Up @@ -317,10 +321,6 @@
"default": "mapbox",
"doc": "The encoding used by this source. Mapbox Terrain RGB is used by default"
},
"promoteId": {
"type": "promoteId",
"doc": "A property to use as a feature id (for feature state). Either a property name, or an object of the form `{<sourceLayer>: <propertyName>}`."
},
"*": {
"type": "*",
"doc": "Other keys to configure the data source."
Expand Down Expand Up @@ -5786,5 +5786,11 @@
"type": "property-type",
"doc": "Property is constant across all zoom levels and property values."
}
},
"promoteId": {
"*": {
"type": "string",
"doc": "A name of a feature property to use as ID for feature state."
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,161 @@
{
"version": 8,
"metadata": {
"test": {
"height": 128,
"width": 512,
"operations": [
[
"setFeatureState",
{
"source": "geojson",
"id": "9007199254740992"
},
{
"color": "red"
}
],
[
"setFeatureState",
{
"source": "geojson",
"id": "1.2"
},
{
"color": "blue"
}
],
[
"wait"
]
]
}
},
"sources": {
"geojson": {
"type": "geojson",
"promoteId": "foo",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.0005,
-0.0001
],
[
-0.0005,
0.0001
],
[
-0.0003,
0.0001
],
[
-0.0003,
-0.0001
],
[
-0.0005,
-0.0001
]
]
]
},
"properties": {
"foo": "9007199254740992"
}
}, {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
-0.0001,
-0.0001
],
[
-0.0001,
0.0001
],
[
0.0001,
0.0001
],
[
0.0001,
-0.0001
],
[
-0.0001,
-0.0001
]
]
]
},
"properties": {
"foo": "9007199254740993"
}
}, {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
0.0003,
-0.0001
],
[
0.0003,
0.0001
],
[
0.0005,
0.0001
],
[
0.0005,
-0.0001
],
[
0.0003,
-0.0001
]
]
]
},
"properties": {
"foo": "1.2"
}
}]
}
}
},
"pitch": 60,
"zoom": 18,
"layers": [
{
"id": "fill-extrusion",
"type": "fill-extrusion",
"source": "geojson",
"paint": {
"fill-extrusion-height": 10,
"fill-extrusion-base": 0,
"fill-extrusion-color": [
"coalesce",
[
"feature-state",
"color"
],
"black"
]
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions test/integration/render-tests/feature-state/promote-id-fill/style.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"version": 8,
"metadata": {
"test": {
"width": 64,
"height": 32,
"operations": [
[
"setFeatureState",
{
"source": "geojson",
"id": "9007199254740992"
},
{
"color": "red"
}
],
[
"setFeatureState",
{
"source": "geojson",
"id": "1.2"
},
{
"color": "blue"
}
],
[
"wait"
]
]
}
},
"zoom": 2,
"sources": {
"geojson": {
"type": "geojson",
"promoteId": "foo",
"data": {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ -5, -1 ],
[ -5, 1 ],
[ -3, 1 ],
[ -3, -1 ],
[ -5, -1 ]
]
]
},
"properties": {
"foo": "9007199254740992"
}
}, {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ -1, -1 ],
[ -1, 1 ],
[ 1, 1 ],
[ 1, -1 ],
[ -0.5, -1 ]
]
]
},
"properties": {
"foo": "9007199254740993"
}
}, {
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[ 3, -1 ],
[ 3, 1 ],
[ 5, 1 ],
[ 5, -1 ],
[ 3, -1 ]
]
]
},
"properties": {
"foo": "1.2"
}
}]
}
}
},
"layers": [
{
"id": "fill",
"type": "fill",
"source": "geojson",
"paint": {
"fill-antialias": false,
"fill-color": [
"coalesce",
[
"feature-state",
"color"
],
"black"
]
}
}
]
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading