diff --git a/packages/geo/src/lib/feature/shared/store.ts b/packages/geo/src/lib/feature/shared/store.ts index 178dc4b6a7..21f1c0c2b4 100644 --- a/packages/geo/src/lib/feature/shared/store.ts +++ b/packages/geo/src/lib/feature/shared/store.ts @@ -182,12 +182,11 @@ export class FeatureStore extends EntityStore { this.addOlFeaturesToLayer(olFeaturesToAdd); } - // Determine the move action to take if (olFeaturesToAdd.length > 0) { + // If features are added, do a motion toward the newly added features moveToFeatures(this.map, olFeaturesToAdd, motion); - } else if (olFeaturesToRemove.length > 0) { - // Do nothing } else if (olFeatures.length > 0) { + // Else, do a motion toward all the features moveToFeatures(this.map, olFeatures, motion); } } diff --git a/packages/geo/src/lib/feature/shared/strategies/loading.ts b/packages/geo/src/lib/feature/shared/strategies/loading.ts index bbae9adbc6..fcc4c59d90 100644 --- a/packages/geo/src/lib/feature/shared/strategies/loading.ts +++ b/packages/geo/src/lib/feature/shared/strategies/loading.ts @@ -106,7 +106,18 @@ export class FeatureStoreLoadingStrategy extends FeatureStoreStrategy { if (features.length === 0) { store.clearLayer(); } else { - store.setLayerFeatures(features, FeatureMotion.None); + let motion; + if (store.pristine === true) { + // If features have just been loaded into the store, move/zoom on them + motion = FeatureMotion.Default; + } else if (store.count > store.view.count) { + // If features have been filtered, move/zoom on the remaining ones + motion = FeatureMotion.Default; + } else { + // On insert, update or delete, do nothing + motion = FeatureMotion.None; + } + store.setLayerFeatures(features, motion); } } }