Skip to content

Commit

Permalink
[viz] Allow for configurable map urls
Browse files Browse the repository at this point in the history
  • Loading branch information
jbudz committed Jul 12, 2016
1 parent 8b4c402 commit 4a5b0d3
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/core_plugins/kibana/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ module.exports = function (kibana) {

injectVars: function (server, options) {
let config = server.config();

return {
kbnDefaultAppId: config.get('kibana.defaultAppId')
kbnDefaultAppId: config.get('kibana.defaultAppId'),
tilemap: config.get('tilemap')
};
},
},
Expand Down
9 changes: 8 additions & 1 deletion src/core_plugins/tests_bundle/tests_entry_template.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@ window.__KBN__ = {
kbnIndex: '.kibana',
esShardTimeout: 1500,
esApiVersion: '2.0',
esRequestTimeout: '300000'
esRequestTimeout: '300000',
tilemap: {
url: 'https://tiles.elastic.co/v1/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana',
subdomains: [],
minZoom: 1,
maxZoom: 8,
attribution: '© [Elastic Tile Service](https://www.elastic.co/elastic_tile_service_tos)'
}
},
uiSettings: {
defaults: ${JSON.stringify(env.defaultUiSettings, null, 2).split('\n').join('\n ')},
Expand Down
10 changes: 9 additions & 1 deletion src/server/config/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,14 @@ module.exports = () => Joi.object({

status: Joi.object({
allowAnonymous: Joi.boolean().default(false)
}).default()
}).default(),

tilemap: Joi.object({
url: Joi.string().default('https://tiles.elastic.co/v1/default/{z}/{x}/{y}.png?elastic_tile_service_tos=agree&my_app_name=kibana'),
subdomains: Joi.array().items(Joi.string()).default([]),
minZoom: Joi.number().default(1),
maxZoom: Joi.number().default(8),
attribution: Joi.string().default('© [Elastic Tile Service](https://www.elastic.co/elastic_tile_service_tos)')
}).default(),

}).default();
4 changes: 4 additions & 0 deletions src/ui/public/vislib/styles/_tilemap.less
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@
.leaflet-control-attribution {
background-color: @tilemap-leaflet-footer-bg !important;
color: @tilemap-leaflet-footer-color !important;

p {
display: inline;
}
}

.leaflet-left {
Expand Down
20 changes: 12 additions & 8 deletions src/ui/public/vislib/visualizations/_map.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,27 @@
import _ from 'lodash';
import $ from 'jquery';
import L from 'leaflet';
import marked from 'marked';
marked.setOptions({
gfm: true, // Github-flavored markdown
sanitize: true // Sanitize HTML tags
});

import VislibVisualizationsMarkerTypesScaledCirclesProvider from 'ui/vislib/visualizations/marker_types/scaled_circles';
import VislibVisualizationsMarkerTypesShadedCirclesProvider from 'ui/vislib/visualizations/marker_types/shaded_circles';
import VislibVisualizationsMarkerTypesGeohashGridProvider from 'ui/vislib/visualizations/marker_types/geohash_grid';
import VislibVisualizationsMarkerTypesHeatmapProvider from 'ui/vislib/visualizations/marker_types/heatmap';
export default function MapFactory(Private) {
export default function MapFactory(Private, tilemap) {

let defaultMapZoom = 2;
let defaultMapCenter = [15, 5];
let defaultMarkerType = 'Scaled Circle Markers';

let mapTiles = {
url: 'https://otile{s}-s.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg',
url: tilemap.url,
options: {
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'
attribution: marked(tilemap.attribution),
subdomains: tilemap.subdomains
}
};

Expand Down Expand Up @@ -52,8 +56,8 @@ export default function MapFactory(Private) {
this._attr = params.attr || {};

let mapOptions = {
minZoom: 1,
maxZoom: 18,
minZoom: tilemap.minZoom,
maxZoom: tilemap.maxZoom,
noWrap: true,
maxBounds: L.latLngBounds([-90, -220], [90, 220]),
scrollWheelZoom: false,
Expand Down

0 comments on commit 4a5b0d3

Please sign in to comment.