When using WMS, the zoom settings of the manifest should not be used (#11707)

When a user configures a WMS, we should not use the zoom-settings from the manifest. These depend on the user's license level, and are not relevant when using a 3rd party WMS service.
This commit is contained in:
Thomas Neirynck 2017-05-11 09:32:03 -04:00 committed by GitHub
parent 070a8a4669
commit c946b43f3e
5 changed files with 83 additions and 6 deletions

View file

@ -293,6 +293,10 @@ export class KibanaMap extends EventEmitter {
return this._leafletMap.getZoom(); return this._leafletMap.getZoom();
} }
getMaxZoomLevel() {
return this._leafletMap.getMaxZoom();
}
getAutoPrecision() { getAutoPrecision() {
return zoomToPrecision(this._leafletMap.getZoom(), 12, this._leafletMap.getMaxZoom()); return zoomToPrecision(this._leafletMap.getZoom(), 12, this._leafletMap.getMaxZoom());
} }

View file

@ -12,7 +12,6 @@ uiModules.get('kibana')
.service('tilemapSettings', function ($http, tilemapsConfig, $sanitize, kbnVersion) { .service('tilemapSettings', function ($http, tilemapsConfig, $sanitize, kbnVersion) {
const attributionFromConfig = $sanitize(marked(tilemapsConfig.deprecated.config.options.attribution || '')); const attributionFromConfig = $sanitize(marked(tilemapsConfig.deprecated.config.options.attribution || ''));
const optionsFromConfig = _.assign({}, tilemapsConfig.deprecated.config.options, { attribution: attributionFromConfig }); const optionsFromConfig = _.assign({}, tilemapsConfig.deprecated.config.options, { attribution: attributionFromConfig });
const extendUrl = (url, props) => ( const extendUrl = (url, props) => (
modifyUrl(url, parsed => _.merge(parsed, props)) modifyUrl(url, parsed => _.merge(parsed, props))
); );

View file

@ -24,6 +24,7 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin
this._buildChartData = buildChartData.bind(this); this._buildChartData = buildChartData.bind(this);
this._geohashLayer = null; this._geohashLayer = null;
this._kibanaMap = null; this._kibanaMap = null;
this._$container = $el;
this._kibanaMapReady = this._makeKibanaMap($el); this._kibanaMapReady = this._makeKibanaMap($el);
this._baseLayerDirty = true; this._baseLayerDirty = true;
@ -39,7 +40,7 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin
}); });
} }
async _makeKibanaMap($el) { async _makeKibanaMap() {
if (!tilemapSettings.isInitialized()) { if (!tilemapSettings.isInitialized()) {
await tilemapSettings.loadSettings(); await tilemapSettings.loadSettings();
@ -51,8 +52,11 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin
notify.warning(tilemapSettings.getError().message); notify.warning(tilemapSettings.getError().message);
} }
const containerElement = $($el)[0]; if (this._kibanaMap) {
const options = _.clone(tilemapSettings.getMinMaxZoom(false)); this._kibanaMap.destroy();
}
const containerElement = $(this._$container)[0];
const options = _.clone(this._getMinMaxZoom());
const uiState = this.vis.getUiState(); const uiState = this.vis.getUiState();
const zoomFromUiState = parseInt(uiState.get('mapZoom')); const zoomFromUiState = parseInt(uiState.get('mapZoom'));
const centerFromUIState = uiState.get('mapCenter'); const centerFromUIState = uiState.get('mapCenter');
@ -104,6 +108,11 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin
}); });
} }
_getMinMaxZoom() {
const mapParams = this._getMapsParams();
return tilemapSettings.getMinMaxZoom(mapParams.wms.enabled);
}
_recreateGeohashLayer() { _recreateGeohashLayer() {
if (this._geohashLayer) { if (this._geohashLayer) {
this._kibanaMap.removeLayer(this._geohashLayer); this._kibanaMap.removeLayer(this._geohashLayer);
@ -146,10 +155,17 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin
updateParams() { updateParams() {
this._paramsDirty = true; this._paramsDirty = true;
this._kibanaMapReady.then(() => { this._kibanaMapReady.then(async() => {
const mapParams = this._getMapsParams(); const mapParams = this._getMapsParams();
const { minZoom, maxZoom } = this._getMinMaxZoom();
if (mapParams.wms.enabled) { if (mapParams.wms.enabled) {
const { minZoom, maxZoom } = tilemapSettings.getMinMaxZoom(true);
if (maxZoom > this._kibanaMap.getMaxZoomLevel()) {
this._geohashLayer = null;
this._kibanaMapReady = this._makeKibanaMap();
}
this._kibanaMap.setBaseLayer({ this._kibanaMap.setBaseLayer({
baseLayerType: 'wms', baseLayerType: 'wms',
options: { options: {
@ -160,6 +176,13 @@ module.exports = function MapsRenderbotFactory(Private, $injector, tilemapSettin
} }
}); });
} else { } else {
if (maxZoom < this._kibanaMap.getMaxZoomLevel()) {
this._geohashLayer = null;
this._kibanaMapReady = this._makeKibanaMap();
this._kibanaMap.setZoomLevel(maxZoom);
}
if (!tilemapSettings.hasError()) { if (!tilemapSettings.hasError()) {
const url = tilemapSettings.getUrl(); const url = tilemapSettings.getUrl();
const options = tilemapSettings.getTMSOptions(); const options = tilemapSettings.getTMSOptions();

View file

@ -305,6 +305,42 @@ export default function ({ getService, getPageObjects }) {
expect(enabled).to.be(false); expect(enabled).to.be(false);
}); });
}); });
it('wms switch should change allow to zoom in further', function () {
return PageObjects.visualize.collapseChart()
.then(function () {
return PageObjects.visualize.clickOptions();
})
.then(function () {
return PageObjects.visualize.selectWMS();
})
.then(function () {
return PageObjects.visualize.clickGo();
})
.then(function () {
return PageObjects.header.waitUntilLoadingHasFinished();
})
.then(function () {
return PageObjects.common.sleep(2000);
})
.then(function () {
return PageObjects.visualize.getMapZoomInEnabled();
})
.then(function (enabled) {//should be able to zoom in again
expect(enabled).to.be(true);
})
.then(function () {
return PageObjects.visualize.clickMapZoomIn();
})
.then(function () {
return PageObjects.visualize.getMapZoomInEnabled();
})
.then(function (enabled) {//should be able to zoom in again
expect(enabled).to.be(true);
});
});
}); });
}); });
} }

View file

@ -325,6 +325,21 @@ export function VisualizePageProvider({ getService, getPageObjects }) {
}); });
} }
clickOptions() {
return remote
.setFindTimeout(defaultFindTimeout)
.findByPartialLinkText('Options')
.click();
}
selectWMS() {
return remote
.setFindTimeout(defaultFindTimeout)
.findByCssSelector('input[name="wms.enabled"]')
.click();
}
saveVisualization(vizName) { saveVisualization(vizName) {
return testSubjects.click('visualizeSaveButton') return testSubjects.click('visualizeSaveButton')
.then(() => { .then(() => {