mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Use correct WMS zoom settings (#9895)
use hardcoded zoom-values for WMS, just as in pre 5.2 Backport of #9868.
This commit is contained in:
parent
1269d3cd05
commit
06a8b34016
5 changed files with 49 additions and 19 deletions
|
@ -115,7 +115,7 @@ describe('tilemaptest - TileMap Map Tests', function () {
|
|||
it('should create layer with all options from `tilemapSettings.getOptions()`', () => {
|
||||
sinon.assert.calledOnce(L.tileLayer);
|
||||
|
||||
const leafletOptions = tilemapSettings.getOptions();
|
||||
const leafletOptions = tilemapSettings.getTMSOptions();
|
||||
expect(L.tileLayer.firstCall.args[1]).to.eql(leafletOptions);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -53,7 +53,7 @@ describe('tilemaptest - TileMapSettingsTests-deprecated', function () {
|
|||
});
|
||||
|
||||
it('should get options', function () {
|
||||
const options = tilemapSettings.getOptions();
|
||||
const options = tilemapSettings.getTMSOptions();
|
||||
expect(options).to.have.property('minZoom');
|
||||
expect(options).to.have.property('maxZoom');
|
||||
expect(options).to.have.property('attribution');
|
||||
|
|
|
@ -94,7 +94,7 @@ describe('tilemaptest - TileMapSettingsTests-mocked', function () {
|
|||
});
|
||||
|
||||
it('should get options', async function () {
|
||||
const options = tilemapSettings.getOptions();
|
||||
const options = tilemapSettings.getTMSOptions();
|
||||
expect(options).to.have.property('minZoom', 0);
|
||||
expect(options).to.have.property('maxZoom', 12);
|
||||
expect(options).to.have.property('attribution').contain('©'); // html entity for ©, ensures that attribution is escaped
|
||||
|
|
|
@ -50,7 +50,7 @@ uiModules.get('kibana')
|
|||
|
||||
//initialize settings with the default of the configuration
|
||||
this._url = tilemapsConfig.deprecated.config.url;
|
||||
this._options = optionsFromConfig;
|
||||
this._tmsOptions = optionsFromConfig;
|
||||
|
||||
this._invalidateSettings();
|
||||
|
||||
|
@ -75,7 +75,7 @@ uiModules.get('kibana')
|
|||
const manifest = response.data;
|
||||
this._error = null;
|
||||
|
||||
this._options = {
|
||||
this._tmsOptions = {
|
||||
attribution: $sanitize(marked(manifest.services[0].attribution)),
|
||||
minZoom: manifest.services[0].minZoom,
|
||||
maxZoom: manifest.services[0].maxZoom,
|
||||
|
@ -102,7 +102,7 @@ uiModules.get('kibana')
|
|||
}
|
||||
|
||||
/**
|
||||
* Must be called before getUrl/getOptions can be called.
|
||||
* Must be called before getUrl/getTMSOptions/getMapOptions can be called.
|
||||
*/
|
||||
loadSettings() {
|
||||
return this._loadSettings();
|
||||
|
@ -149,13 +149,39 @@ uiModules.get('kibana')
|
|||
* Get the options of the default TMS
|
||||
* @return {{}}
|
||||
*/
|
||||
getOptions() {
|
||||
getTMSOptions() {
|
||||
if (!this._settingsInitialized) {
|
||||
throw new Error('Cannot retrieve options before calling .loadSettings first');
|
||||
}
|
||||
return this._options;
|
||||
return this._tmsOptions;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return {{maxZoom: (*|number), minZoom: (*|number)}}
|
||||
*/
|
||||
getMinMaxZoom(isWMSEnabled) {
|
||||
|
||||
//for backward compatibilty, we preserve the 1-18 setting. https://git.io/vMn5o
|
||||
if (isWMSEnabled) {
|
||||
return {
|
||||
minZoom: 1,
|
||||
maxZoom: 18
|
||||
};
|
||||
}
|
||||
|
||||
//Otherwise, we use the settings from the yml.
|
||||
//note that it is no longer possible to only override the zoom-settings, since all options are read from the manifest
|
||||
//by default.
|
||||
//For a custom configuration, users will need to override tilemap.url as well.
|
||||
return {
|
||||
minZoom: this._tmsOptions.minZoom,
|
||||
maxZoom: this._tmsOptions.maxZoom
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks if there was an error during initialization of the parameters
|
||||
*/
|
||||
|
@ -170,7 +196,7 @@ uiModules.get('kibana')
|
|||
/**
|
||||
* Make this a method to allow for overrides by test code
|
||||
*/
|
||||
_getTileServiceManifest(manifestUrl, additionalQueryParams) {
|
||||
_getTileServiceManifest(manifestUrl) {
|
||||
return $http({
|
||||
url: extendUrl(manifestUrl, { query: this._queryParams }),
|
||||
method: 'GET'
|
||||
|
|
|
@ -40,12 +40,12 @@ export default function MapFactory(Private, tilemapSettings) {
|
|||
this._valueFormatter = params.valueFormatter || _.identity;
|
||||
this._tooltipFormatter = params.tooltipFormatter || _.identity;
|
||||
this._geoJson = _.get(this._chartData, 'geoJson');
|
||||
|
||||
const mapOptions = tilemapSettings.getOptions();
|
||||
this._mapZoom = Math.max(Math.min(params.zoom || defaultMapZoom, mapOptions.maxZoom), mapOptions.minZoom);
|
||||
this._mapCenter = params.center || defaultMapCenter;
|
||||
this._attr = params.attr || {};
|
||||
|
||||
const { minZoom, maxZoom } = tilemapSettings.getMinMaxZoom(this._isWMSEnabled());
|
||||
this._mapZoom = Math.max(Math.min(params.zoom || defaultMapZoom, maxZoom), minZoom);
|
||||
this._mapCenter = params.center || defaultMapCenter;
|
||||
|
||||
this._createMap();
|
||||
}
|
||||
|
||||
|
@ -283,21 +283,25 @@ export default function MapFactory(Private, tilemapSettings) {
|
|||
});
|
||||
};
|
||||
|
||||
_isWMSEnabled() {
|
||||
return this._attr.wms ? this._attr.wms.enabled : false;
|
||||
}
|
||||
|
||||
_createTileLayer() {
|
||||
const wmsOpts = this._attr.wms || { enabled: false };
|
||||
if (wmsOpts.enabled) {
|
||||
if (this._isWMSEnabled()) {
|
||||
const wmsOpts = this._attr.wms;
|
||||
const { minZoom, maxZoom } = tilemapSettings.getMinMaxZoom(true);
|
||||
// http://leafletjs.com/reference.html#tilelayer-wms-options
|
||||
return L.tileLayer.wms(wmsOpts.url, {
|
||||
// user settings
|
||||
...wmsOpts.options,
|
||||
// override the min/maz zoom levels, https://git.io/vMn5o
|
||||
minZoom: 1,
|
||||
maxZoom: 18,
|
||||
minZoom: minZoom,
|
||||
maxZoom: maxZoom,
|
||||
});
|
||||
}
|
||||
|
||||
const tileUrl = tilemapSettings.hasError() ? '' : tilemapSettings.getUrl();
|
||||
const leafletOptions = tilemapSettings.getOptions();
|
||||
const leafletOptions = tilemapSettings.getTMSOptions();
|
||||
return L.tileLayer(tileUrl, leafletOptions);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue