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

Configurable tile map #2605

Closed
wants to merge 11 commits into from
17 changes: 16 additions & 1 deletion src/kibana/components/config/defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ define(function (require) {
value: 6,
description: 'The maximum geoHash size allowed in a tile map',
},
'visualization:tileMap:wms': {
value: false,
description: 'Set for a WMS mapping provider, see <a href="http://leafletjs.com/reference.html#tilelayer-wms">leafletjs reference</a>'
Copy link
Contributor

Choose a reason for hiding this comment

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

The link here indicates this controls a function that takes an object, but the value is a boolean? I think I understand from the code what this is supposed todo, but I don't think other users will.

Also note that all links should target an empty window to avoid redirecting the user out of the application when they click them.

},
'visualization:tileMap:url': {
value: 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg',
description: 'URL of mapping provider, see <a href="http://leafletjs.com/reference.html#tilelayer">leafletjs reference</a>' +
' or <a href="http://leaflet-extras.github.io/leaflet-providers/preview/">provider demos</a>'
},
'visualization:tileMap:options': {
value: null,
description: 'TileLayer options, see <a href="http://leafletjs.com/reference.html#tilelayer">leafletjs reference</a>' +
' or <a href="http://leaflet-extras.github.io/leaflet-providers/preview/">provider demos</a>',
type: 'json'
},
'csv:separator': {
value: ',',
description: 'Separate exported values with this string',
Expand All @@ -64,4 +79,4 @@ define(function (require) {
description: 'The maximum height that a cell in a table should occupy. Set to 0 to disable truncation.'
}
};
});
});
20 changes: 13 additions & 7 deletions src/kibana/components/vislib/visualizations/tile_map.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
define(function (require) {
return function TileMapFactory(d3, Private) {
return function TileMapFactory(d3, Private, config) {
var _ = require('lodash');
var $ = require('jquery');
var L = require('leaflet');
Expand Down Expand Up @@ -71,12 +71,18 @@ define(function (require) {
}

var featureLayer;
var tileLayer = L.tileLayer('http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg', {
attribution: 'Tiles by <a href="http://www.mapquest.com/">MapQuest</a> &mdash; ' +
'Map data &copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' +
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
subdomains: '1234'
});
var tileLayer;
var tileOptions = config.get('visualization:tileMap:options', '{' +
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather see the 2nd argument of this be an object vs a concatenated string

'"attribution": "Tiles by <a href=\\"http://www.mapquest.com/\\">MapQuest</a> &mdash; ' +
'Map data &copy; <a href=\\"http://openstreetmap.org\\">OpenStreetMap</a> contributors, ' +
'<a href=\\"http://creativecommons.org/licenses/by-sa/2.0/\\">CC-BY-SA</a>\", ' +
'"subdomains": "1234" }'
);
if (config.get('visualization:tileMap:wms')) {
tileLayer = L.tileLayer.wms(config.get('visualization:tileMap:url'), tileOptions);
} else {
tileLayer = L.tileLayer(config.get('visualization:tileMap:url'), tileOptions);
}

var mapOptions = {
minZoom: 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
(Default: <i>{{conf.defVal == undefined ? 'null' : conf.defVal}}</i>)
</span>
<br>
<span class="smaller">{{conf.description}}</span>
<span class="smaller" ng-bind-html="conf.description | trustAsHtml"></span>
</td>
<td class="value">
<form
Expand Down Expand Up @@ -81,4 +81,4 @@
<i class="fa fa-times"></i>
</button>
</td>
</tr>
</tr>