Skip to content

Commit

Permalink
Don't reset feature state
Browse files Browse the repository at this point in the history
  • Loading branch information
jfirebaugh committed Aug 16, 2018
1 parent 53d2a43 commit 2d0c4bc
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
3 changes: 0 additions & 3 deletions src/source/source_cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,6 @@ class SourceCache extends Evented {
}

this._cache.reset();
//Reset the SourceCache when the source has been reloaded. For GeoJSON sources,
// the `id` of features is not guaranteed to be identical when updated
this._state = new SourceFeatureState();

for (const i in this._tiles) {
if (this._tiles[i].state !== "errored") this._reloadTile(i, 'reloading');
Expand Down
2 changes: 1 addition & 1 deletion src/style-spec/reference/v8.json
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@
"generateId": {
"type": "boolean",
"default": false,
"doc": "Whether to generate ids for the geojson features. When enabled, the `feature.id` property will be auto assigned based on it's index in the `features` array, over-writing any previous values."
"doc": "Whether to generate ids for the geojson features. When enabled, the `feature.id` property will be auto assigned based on its index in the `features` array, over-writing any previous values."
}
},
"source_video": {
Expand Down
9 changes: 4 additions & 5 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -1345,11 +1345,10 @@ class Map extends Camera {
* required.*
* @param {Object} state A set of key-value pairs. The values should be valid JSON types.
*
* This method requires the `feature.id` attribute on data sets. For GeoJSON sources without
* feature ids, set the `generateIds` option in the `GeoJSONSourceSpecification` to auto-assign them. This
* option assigns ids based on a feature's index in the source data. Changing the feature data using
* `map.getSource('some id').setData(..)` resets the cache of feature states and requires the
* caller re-apply the state as needed with the updated `id` values.
* This method requires the `feature.id` attribute on data sets. For GeoJSON sources without
* feature ids, set the `generateIds` option in the `GeoJSONSourceSpecification` to auto-assign them. This
* option assigns ids based on a feature's index in the source data. If you change feature data using
* `map.getSource('some id').setData(..)`, you may need to re-apply state taking into account updated `id` values.
*/
setFeatureState(feature: { source: string; sourceLayer?: string; id: string | number; }, state: Object) {
this.style.setFeatureState(feature, state);
Expand Down

0 comments on commit 2d0c4bc

Please sign in to comment.