Skip to content

Commit

Permalink
Add maxzoom for permalink search
Browse files Browse the repository at this point in the history
  • Loading branch information
llienher committed Mar 12, 2018
1 parent 3586eef commit 284736f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 32 deletions.
31 changes: 0 additions & 31 deletions contribs/gmf/src/controllers/abstract.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ goog.require('gmf.mapDirective');
/** @suppress {extraRequire} */
goog.require('gmf.searchDirective');
/** @suppress {extraRequire} */
goog.require('gmf.FulltextSearchService');
/** @suppress {extraRequire} */
goog.require('gmf.themeselectorDirective');
/** @suppress {extraRequire} */
goog.require('ngeo.BackgroundLayerMgr');
Expand Down Expand Up @@ -513,17 +511,6 @@ gmf.AbstractController = function(config, $scope, $injector) {
cgxp.tools.openInfoWindow = function(url, title, opt_width, opt_height) {
gmfx.openIframePopup(url, title, opt_width, opt_height);
};

/**
* @private
*/
this.fullTextSearch_ = $injector.get('gmfFulltextSearchService');

const searchQuery = this.ngeoLocation.getParam('search');
if (searchQuery) {
const overlay = ngeoFeatureOverlayMgr.getFeatureOverlay();
this.search_(searchQuery, overlay);
}
};


Expand Down Expand Up @@ -632,22 +619,4 @@ gmf.AbstractController.prototype.updateCurrentTheme_ = function(fallbackThemeNam
});
};

/**
* Performs a full-text search and centers the map on the first search result.
* @param {string} query Search query.
* @param {ngeo.FeatureOverlay} overlay Feature overlay to add the feature if found.
* @private
*/
gmf.AbstractController.prototype.search_ = function(query, overlay) {
this.fullTextSearch_.search(query, {'limit': 1})
.then((data) => {
if (data && data.features[0]) {
const format = new ol.format.GeoJSON();
const feature = format.readFeature(data.features[0]);
overlay.addFeature(feature);
this.map.getView().fit(feature.getGeometry().getExtent());
}
});
};

gmf.module.controller('AbstractController', gmf.AbstractController);
9 changes: 8 additions & 1 deletion contribs/gmf/src/directives/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,9 @@ gmf.SearchController.prototype.$onInit = function() {
if (this.ngeoLocation_.getParam('search-select-index')) {
resultIndex = parseInt(this.ngeoLocation_.getParam('search-select-index'), 10);
}
if (this.ngeoLocation_.getParam('search-maxzoom')) {
this.maxZoom = this.ngeoLocation_.getParam('search-maxzoom') || 16;
}
this.fulltextsearch_(searchQuery, resultIndex);
}
}
Expand Down Expand Up @@ -981,8 +984,12 @@ gmf.SearchController.prototype.fulltextsearch_ = function(query, resultIndex) {
if (data && data.features[resultIndex - 1]) {
const format = new ol.format.GeoJSON();
const feature = format.readFeature(data.features[resultIndex - 1]);
const size = this.map_.getSize();
this.featureOverlay_.addFeature(feature);
this.map_.getView().fit(feature.getGeometry().getExtent());
this.map_.getView().fit(feature.getGeometry().getExtent(), {
size,
maxZoom: this.maxZoom
});
this.inputValue = /** @type {string} */ (feature.get('label'));
}
});
Expand Down

0 comments on commit 284736f

Please sign in to comment.