diff --git a/src/plugins/kbn_vislib_vis_types/public/editors/tile_map.html b/src/plugins/kbn_vislib_vis_types/public/editors/tile_map.html
index 3bdb8d15a705f..e4b1f6091afc4 100644
--- a/src/plugins/kbn_vislib_vis_types/public/editors/tile_map.html
+++ b/src/plugins/kbn_vislib_vis_types/public/editors/tile_map.html
@@ -113,6 +113,85 @@
Desaturate map tiles
-
+
+
+
+
+
+
diff --git a/src/plugins/kbn_vislib_vis_types/public/tileMap.js b/src/plugins/kbn_vislib_vis_types/public/tileMap.js
index 8a3046561b968..0b7860a5147ca 100644
--- a/src/plugins/kbn_vislib_vis_types/public/tileMap.js
+++ b/src/plugins/kbn_vislib_vis_types/public/tileMap.js
@@ -22,6 +22,7 @@ define(function (require) {
heatRadius: 25,
heatBlur: 15,
heatNormalizeData: true,
+ wms: config.get('visualization:tileMap:WMSdefaults')
},
mapTypes: ['Scaled Circle Markers', 'Shaded Circle Markers', 'Shaded Geohash Grid', 'Heatmap'],
canDesaturate: !!supports.cssFilters,
diff --git a/src/ui/public/config/defaults.js b/src/ui/public/config/defaults.js
index e21442aa34879..17eef4e7f760e 100644
--- a/src/ui/public/config/defaults.js
+++ b/src/ui/public/config/defaults.js
@@ -74,6 +74,22 @@ define(function () {
'12 is the max. Explanation of cell dimensions: http://www.elastic.co/guide/en/elasticsearch/reference/current/' +
'search-aggregations-bucket-geohashgrid-aggregation.html#_cell_dimensions_at_the_equator',
},
+ 'visualization:tileMap:WMSdefaults': {
+ value: JSON.stringify({
+ enabled: false,
+ url: 'http://basemap.nationalmap.gov/arcgis/services/USGSTopo/MapServer/WMSServer',
+ options: {
+ version: '1.3.0',
+ layers: '0',
+ format: 'image/png',
+ transparent: true,
+ attribution: 'Maps provided by USGS',
+ styles: '',
+ }
+ }, null, ' '),
+ type: 'json',
+ description: 'Default properties for the WMS map server support in the tile map'
+ },
'csv:separator': {
value: ',',
description: 'Separate exported values with this string',
diff --git a/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js b/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js
index 3a276f0d04149..c10ef8dde5dff 100644
--- a/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js
+++ b/src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js
@@ -35,6 +35,8 @@ describe('TileMap Map Tests', function () {
leafletMocks.tileLayer = { on: sinon.stub() };
leafletMocks.map = { on: sinon.stub() };
leafletStubs.tileLayer = sinon.stub(L, 'tileLayer', _.constant(leafletMocks.tileLayer));
+ leafletStubs.tileLayer.wms = sinon.stub(L.tileLayer, 'wms', _.constant(leafletMocks.tileLayer));
+
leafletStubs.map = sinon.stub(L, 'map', _.constant(leafletMocks.map));
TileMapMap = Private(require('ui/vislib/visualizations/_map'));
@@ -96,6 +98,14 @@ describe('TileMap Map Tests', function () {
map._createMap({});
expect(mapStubs.destroy.callCount).to.equal(1);
});
+
+ it('should create a WMS layer if WMS is enabled', function () {
+ expect(L.tileLayer.wms.called).to.be(false);
+ map = new TileMapMap($mockMapEl, geoJsonData, {attr: {wms: {enabled: true}}});
+ map._createMap({});
+ expect(L.tileLayer.wms.called).to.be(true);
+ L.tileLayer.restore();
+ });
});
describe('attachEvents', function () {
diff --git a/src/ui/public/vislib/visualizations/_map.js b/src/ui/public/vislib/visualizations/_map.js
index 1078731bd621c..3cdbe743bb10e 100644
--- a/src/ui/public/vislib/visualizations/_map.js
+++ b/src/ui/public/vislib/visualizations/_map.js
@@ -264,7 +264,11 @@ define(function (require) {
this._mapZoom = _.get(this._geoJson, 'properties.zoom') || defaultMapZoom;
// add map tiles layer, using the mapTiles object settings
- this._tileLayer = L.tileLayer(mapTiles.url, mapTiles.options);
+ if (this._attr.wms && this._attr.wms.enabled) {
+ this._tileLayer = L.tileLayer.wms(this._attr.wms.url, this._attr.wms.options);
+ } else {
+ this._tileLayer = L.tileLayer(mapTiles.url, mapTiles.options);
+ }
// append tile layers, center and zoom to the map options
mapOptions.layers = this._tileLayer;