mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
parent
81298c43e1
commit
9cc5c0dbd0
3 changed files with 97 additions and 18 deletions
|
@ -127,7 +127,10 @@ export function BaseMapsVisualizationProvider(serviceSettings) {
|
|||
const firstRoadMapLayer = tmsServices.find((s) => {
|
||||
return s.id === 'road_map';//first road map layer
|
||||
});
|
||||
this._setTmsLayer(firstRoadMapLayer);
|
||||
const fallback = firstRoadMapLayer ? firstRoadMapLayer : tmsServices[0];
|
||||
if (fallback) {
|
||||
this._setTmsLayer(firstRoadMapLayer);
|
||||
}
|
||||
} catch (e) {
|
||||
this._notify.warning(e.message);
|
||||
return;
|
||||
|
@ -167,12 +170,10 @@ export function BaseMapsVisualizationProvider(serviceSettings) {
|
|||
}
|
||||
|
||||
async _setTmsLayer(tmsLayer) {
|
||||
if (tmsLayer.maxZoom < this._kibanaMap.getMaxZoomLevel()) {
|
||||
this._kibanaMap.setMinZoom(tmsLayer.minZoom);
|
||||
this._kibanaMap.setMaxZoom(tmsLayer.maxZoom);
|
||||
if (this._kibanaMap.getZoomLevel() > tmsLayer.maxZoom) {
|
||||
this._kibanaMap.setZoomLevel(tmsLayer.maxZoom);
|
||||
}
|
||||
this._kibanaMap.setMinZoom(tmsLayer.minZoom);
|
||||
this._kibanaMap.setMaxZoom(tmsLayer.maxZoom);
|
||||
if (this._kibanaMap.getZoomLevel() > tmsLayer.maxZoom) {
|
||||
this._kibanaMap.setZoomLevel(tmsLayer.maxZoom);
|
||||
}
|
||||
const url = tmsLayer.url;
|
||||
const options = _.cloneDeep(tmsLayer);
|
||||
|
|
|
@ -7,7 +7,8 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
|
||||
|
||||
let serviceSettings;
|
||||
let mapsConfig;
|
||||
let mapConfig;
|
||||
let tilemapsConfig;
|
||||
|
||||
const manifestUrl = 'https://geo.elastic.co/v1/manifest';
|
||||
const tmsManifestUrl = `https://tiles.elastic.co/v2/manifest`;
|
||||
|
@ -68,7 +69,6 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
|
||||
|
||||
beforeEach(ngMock.module('kibana', ($provide) => {
|
||||
|
||||
$provide.decorator('mapConfig', () => {
|
||||
return {
|
||||
manifestServiceUrl: manifestUrl,
|
||||
|
@ -77,10 +77,17 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
});
|
||||
}));
|
||||
|
||||
|
||||
let manifestServiceUrlOriginal;
|
||||
let tilemapsConfigDeprecatedOriginal;
|
||||
beforeEach(ngMock.inject(function ($injector, $rootScope) {
|
||||
|
||||
serviceSettings = $injector.get('serviceSettings');
|
||||
mapsConfig = $injector.get('mapConfig');
|
||||
mapConfig = $injector.get('mapConfig');
|
||||
tilemapsConfig = $injector.get('tilemapsConfig');
|
||||
|
||||
manifestServiceUrlOriginal = mapConfig.manifestServiceUrl;
|
||||
tilemapsConfigDeprecatedOriginal = tilemapsConfig.deprecated;
|
||||
|
||||
sinon.stub(serviceSettings, '_getManifest', function (url) {
|
||||
let contents = null;
|
||||
|
@ -102,6 +109,8 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
|
||||
afterEach(function () {
|
||||
serviceSettings._getManifest.restore();
|
||||
mapConfig.manifestServiceUrl = manifestServiceUrlOriginal;
|
||||
tilemapsConfig.deprecated = tilemapsConfigDeprecatedOriginal;
|
||||
});
|
||||
|
||||
describe('TMS', function () {
|
||||
|
@ -166,12 +175,75 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
});
|
||||
|
||||
it('when overridden, should continue to work', async () => {
|
||||
mapsConfig.manifestServiceUrl = manifestUrl2;
|
||||
mapConfig.manifestServiceUrl = manifestUrl2;
|
||||
serviceSettings.addQueryParams({ foo: 'bar' });
|
||||
tilemapServices = await serviceSettings.getTMSServices();
|
||||
assertQuery({ foo: 'bar' });
|
||||
});
|
||||
|
||||
|
||||
it('should merge in tilemap url', async () => {
|
||||
|
||||
tilemapsConfig.deprecated = {
|
||||
'isOverridden': true,
|
||||
'config': {
|
||||
'url': 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
'options': { 'minZoom': 0, 'maxZoom': 20 }
|
||||
}
|
||||
};
|
||||
|
||||
tilemapServices = await serviceSettings.getTMSServices();
|
||||
const expected = [
|
||||
{
|
||||
'attribution': '',
|
||||
'url': 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
'id': 'TMS in config/kibana.yml'
|
||||
},
|
||||
{
|
||||
'id': 'road_map',
|
||||
'url': 'https://tiles.elastic.co/v2/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana&my_app_version=1.2.3',
|
||||
'minZoom': 0,
|
||||
'maxZoom': 10,
|
||||
'attribution': '<p>© <a href="http://www.openstreetmap.org/copyright">OpenStreetMap</a> © <a href="https://www.elastic.co/elastic-maps-service">Elastic Maps Service</a></p> ',
|
||||
'subdomains': []
|
||||
}
|
||||
];
|
||||
expect(tilemapServices).to.eql(expected);
|
||||
|
||||
});
|
||||
|
||||
|
||||
it('should exclude EMS', async () => {
|
||||
|
||||
tilemapsConfig.deprecated = {
|
||||
'isOverridden': true,
|
||||
'config': {
|
||||
'url': 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
'options': { 'minZoom': 0, 'maxZoom': 20 }
|
||||
}
|
||||
};
|
||||
mapConfig.includeElasticMapsService = false;
|
||||
|
||||
tilemapServices = await serviceSettings.getTMSServices();
|
||||
const expected = [
|
||||
{
|
||||
'attribution': '',
|
||||
'url': 'https://a.tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
'id': 'TMS in config/kibana.yml'
|
||||
}
|
||||
];
|
||||
expect(tilemapServices).to.eql(expected);
|
||||
|
||||
});
|
||||
|
||||
it('should exclude all when not configured', async () => {
|
||||
mapConfig.includeElasticMapsService = false;
|
||||
tilemapServices = await serviceSettings.getTMSServices();
|
||||
const expected = [];
|
||||
expect(tilemapServices).to.eql(expected);
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -179,7 +251,6 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
|
||||
describe('File layers', function () {
|
||||
|
||||
|
||||
it('should load manifest', async function () {
|
||||
serviceSettings.addQueryParams({ foo: 'bar' });
|
||||
const fileLayers = await serviceSettings.getFileLayers();
|
||||
|
@ -199,7 +270,12 @@ describe('service_settings (FKA tilemaptest)', function () {
|
|||
});
|
||||
});
|
||||
|
||||
|
||||
it('should exclude all when not configured', async () => {
|
||||
mapConfig.includeElasticMapsService = false;
|
||||
const fileLayers = await serviceSettings.getFileLayers();
|
||||
const expected = [];
|
||||
expect(fileLayers).to.eql(expected);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
|
|
@ -14,8 +14,6 @@ uiModules.get('kibana')
|
|||
const attributionFromConfig = $sanitize(markdownIt.render(tilemapsConfig.deprecated.config.options.attribution || ''));
|
||||
const tmsOptionsFromConfig = _.assign({}, tilemapsConfig.deprecated.config.options, { attribution: attributionFromConfig });
|
||||
|
||||
//todo: also configure min/max zoom levels if they are missing
|
||||
|
||||
const extendUrl = (url, props) => (
|
||||
modifyUrl(url, parsed => _.merge(parsed, props))
|
||||
);
|
||||
|
@ -135,14 +133,18 @@ uiModules.get('kibana')
|
|||
* It also includes the service configured in tilemap (override)
|
||||
*/
|
||||
async getTMSServices() {
|
||||
const allServices = await this._loadTMSServices();
|
||||
|
||||
const allServices = [];
|
||||
if (tilemapsConfig.deprecated.isOverridden) {//use tilemap.* settings from yml
|
||||
const tmsService = _.cloneDeep(tmsOptionsFromConfig);
|
||||
tmsService.url = tilemapsConfig.deprecated.config.url;
|
||||
tmsService.id = 'Tilemap layer in yml';
|
||||
tmsService.id = 'TMS in config/kibana.yml';
|
||||
allServices.push(tmsService);
|
||||
}
|
||||
return allServices;
|
||||
|
||||
const servicesFromManifest = await this._loadTMSServices();
|
||||
return allServices.concat(servicesFromManifest);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue