Skip to content

Commit

Permalink
maxzoomlevel for searchlist (#1919)
Browse files Browse the repository at this point in the history
  • Loading branch information
jokd authored Feb 14, 2024
1 parent e208a42 commit 4dae0b9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/controls/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,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 @@ -391,7 +391,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

0 comments on commit 4dae0b9

Please sign in to comment.