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: maxZoomLevel for searchlist #1919

Merged
merged 1 commit into from
Feb 14, 2024
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/controls/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,7 @@ const Search = function Search(options = {}) {
.then((res) => {
if (res.length > 0) {
const featLayerName = layer.get('name');
featureInfo.showFeatureInfo({ feature: res, layerName: featLayerName });
featureInfo.showFeatureInfo({ feature: res, layerName: featLayerName }, { maxZoomLevel });
}
});
});
Expand Down Expand Up @@ -392,7 +392,7 @@ const Search = function Search(options = {}) {
.then((res) => {
if (res.length > 0) {
const featureLayerName = layer.get('name');
featureInfo.showFeatureInfo({ feature: res, layerName: featureLayerName });
featureInfo.showFeatureInfo({ feature: res, layerName: featureLayerName }, { maxZoomLevel });
}
});
});
Expand Down
12 changes: 9 additions & 3 deletions src/featureinfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -605,9 +605,15 @@ const Featureinfo = function Featureinfo(options = {}) {
* @param {any} featureObj An object containing layerName and feature. "feature" is either one Feature or an Array of Feature
* @param {any} opts An object containing options. Supported options are : coordinate, the coordinate where popup will be shown. If omitted first feature is used.
* ignorePan, do not autopan if type is overlay. Pan should be supressed if view is changed manually to avoid contradicting animations.
* maxZoomLevel, max level for zooming on feature.
* @returns nothing
*/
const showFeatureInfo = function showFeatureInfo(featureObj, opts = { ignorePan: true }) {
const showFeatureInfo = function showFeatureInfo(featureObj, opts) {
const thisOpts = { ...{
ignorePan: true
},
...opts };

const newItems = [];
const layerName = featureObj.layerName;
const layer = viewer.getLayer(layerName);
Expand All @@ -623,8 +629,8 @@ const Featureinfo = function Featureinfo(options = {}) {
newItems.push(newItem);
}
if (newItems.length > 0) {
render(newItems, identifyTarget, opts.coordinate || maputils.getCenter(newItems[0].getFeature().getGeometry()), opts);
viewer.getMap().getView().fit(maputils.getExtent(newItems.map(i => i.getFeature())));
render(newItems, identifyTarget, thisOpts.coordinate || maputils.getCenter(newItems[0].getFeature().getGeometry()), thisOpts);
viewer.getMap().getView().fit(maputils.getExtent(newItems.map(i => i.getFeature())), { maxZoom: thisOpts.maxZoomLevel });
}
};

Expand Down
Loading