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 WMS map server support #4701

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 80 additions & 1 deletion src/plugins/kbn_vislib_vis_types/public/editors/tile_map.html
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,85 @@

Desaturate map tiles

<kbn-info info="Reduce the vibrancy of tile colors, this does not work in any version of Internet Explorer"
<kbn-info info="Reduce the vibrancy of tile colors, this does not work in any version of Internet Explorer"></kbn-info>
</label>
</div>

<div class="vis-option-item form-group">
<label>
<input type="checkbox"
name="wms.enabled"
ng-model="vis.params.wms.enabled">

WMS compliant map server

<kbn-info info="Use WMS compliant map tile server. For advanced users only."></kbn-info>
</label>
</div>

<div ng-show="vis.params.wms.enabled" class="well">
<div class="vis-option-item form-group">

<p>
WMS maps are 3rd party mapping services that have not been verified to work with Kibana.
These should be considered expert settings.
</p>

<label>
WMS url*
</label>
<input type="text" class="form-control"
name="wms.url"
ng-model="vis.params.wms.url">
</div>

<div class="vis-option-item form-group">
<label>
WMS layers* <kbn-info info="A comma seperated list of layers to use."></kbn-info>
</label>
<input type="text" class="form-control"
ng-require="vis.params.wms.enabled"
ng-model="vis.params.wms.options.layers"
name="wms.options.layers">
</div>

<div class="vis-option-item form-group">
<label>
WMS version* <kbn-info info="The version of WMS the server supports"></kbn-info>
</label>
<input type="text" class="form-control"
name="wms.options.version"
ng-model="vis.params.wms.options.version">
</div>

<div class="vis-option-item form-group">
<label>
WMS format* <kbn-info info="Usually image/png or image/jpeg. Use png if the server will return transparent layers"></kbn-info>
</label>
<input type="text" class="form-control"
name="wms.options.format"
ng-model="vis.params.wms.options.format">
</div>

<div class="vis-option-item form-group">
<label>
WMS attribution <kbn-info info="Attribution string for the lower right corner<"></kbn-info>
</label>
<input type="text" class="form-control"
name="wms.options.attribution"
ng-model="vis.params.wms.options.attribution">
</div>

<div class="vis-option-item form-group">
<label>
WMS styles* <kbn-info info="A comma seperated list of WMS server supported styles to use. Blank in most cases."></kbn-info>
</label>
<input type="text" class="form-control"
name="wms.options.styles"
ng-model="vis.params.wms.options.styles">
</div>

<p>* if this parameter is incorrect, maps will fail to load.</p>


</div>
1 change: 1 addition & 0 deletions src/plugins/kbn_vislib_vis_types/public/tileMap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions src/ui/public/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Copy link
Member

Choose a reason for hiding this comment

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

maybe worth using // or https by default

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',
Expand Down
10 changes: 10 additions & 0 deletions src/ui/public/vislib/__tests__/visualizations/tile_maps/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down Expand Up @@ -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 () {
Expand Down
6 changes: 5 additions & 1 deletion src/ui/public/vislib/visualizations/_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down