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

Add max-zoom setting for point geometries for oedit permalinks #4279

Merged
merged 3 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions contribs/gmf/apps/oeedit/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,10 @@
{action: 'add_layer', title: 'Add a layer'}
]);
module.constant('gmfContextualdatacontentTemplateUrl', window.location.pathname + 'contextualdata.html');
module.value('gmfPermalinkOptions',
/** @type {gmfx.PermalinkOptions} */ ({
pointRecenterZoom: 10
}));
module.value('ngeoWfsPermalinkOptions',
/** @type {ngeox.WfsPermalinkOptions} */ ({
url: 'https://geomapfish-demo.camptocamp.net/2.2/wsgi/mapserv_proxy',
Expand Down
11 changes: 10 additions & 1 deletion contribs/gmf/options/gmfx.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ gmfx.ObjectEditingToolsOptions.prototype.regularPolygonRadius;
* crosshairStyle: (Array<(null|ol.style.Style)>|null|ol.FeatureStyleFunction|ol.style.Style|undefined),
* crosshairEnabledByDefault: (boolean|undefined),
* projectionCodes: (Array.<string>|undefined),
* useLocalStorage: (boolean|undefined)
* useLocalStorage: (boolean|undefined),
* pointRecenterZoom: (number|undefined),
* }}
*/
gmfx.PermalinkOptions;
Expand Down Expand Up @@ -207,6 +208,14 @@ gmfx.PermalinkOptions.prototype.projectionCodes;
gmfx.PermalinkOptions.prototype.useLocalStorage;


/**
* Zoom level to use when result is a single point feature. If not set the map
* is not zoomed to a specific zoom level.
* @type {number|undefined}
*/
gmfx.PermalinkOptions.prototype.pointRecenterZoom


/**
* Fields that can come from a print v3 server and can be used in the partial
* of the gmf print panel.
Expand Down
17 changes: 16 additions & 1 deletion contribs/gmf/src/services/permalink.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ goog.require('ngeo.WfsPermalink');
goog.require('goog.asserts');
goog.require('ol.Feature');
goog.require('ol.geom.Point');
goog.require('ol.geom.MultiPoint');
goog.require('ol.proj');
goog.require('ol.style.Stroke');
goog.require('ol.style.RegularShape');
Expand Down Expand Up @@ -187,6 +188,12 @@ gmf.Permalink = function($timeout, $rootScope, $injector, ngeoDebounce, gettextC
*/
this.crosshairEnabledByDefault_ = !!gmfPermalinkOptions.crosshairEnabledByDefault;

/**
* @type {number|undefined}
* @private
*/
this.pointRecenterZoom_ = gmfPermalinkOptions.pointRecenterZoom;

/**
* @type {?gmf.Themes}
* @private
Expand Down Expand Up @@ -700,8 +707,16 @@ gmf.Permalink.prototype.registerMap_ = function(map, oeFeature) {
// b) the X, Y and Z available within the permalink service, if available
if (oeFeature && oeFeature.getGeometry()) {
const size = map.getSize();
const geom = oeFeature.getGeometry();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oeFeature.getGeometry() is already called two line upper. Can you call it once (use the variable) ?

goog.asserts.assert(size);
view.fit(oeFeature.getGeometry().getExtent(), size);
let maxZoom;
if (geom instanceof ol.geom.Point || geom instanceof ol.geom.MultiPoint) {
maxZoom = this.pointRecenterZoom_;
}
view.fit(geom.getExtent(), {
size,
maxZoom
});
} else {
center = this.getMapCenter();
if (center) {
Expand Down