-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Elastic Tile Service and configurable leaflet providers #7724
Changes from all commits
58844a0
0b9388c
b1f8ac8
c670a1c
7c8ec75
6d8f803
b762949
c3d203f
3c1339e
41fbb06
6494caa
c74041c
ca5a968
2feac11
2862f94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,6 +142,10 @@ | |
.leaflet-control-attribution { | ||
background-color: @tilemap-leaflet-footer-bg !important; | ||
color: @tilemap-leaflet-footer-color !important; | ||
|
||
p { | ||
display: inline; | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What does this do? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. running attribution through markdown wraps everything in a p block, causes linebreak |
||
} | ||
|
||
.leaflet-left { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
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 tilemapOptions = tilemap.options; | ||
let attribution = marked(tilemapOptions.attribution); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why markdown instead of HTML? This seems like it would be confusing for users familiar with Leaflet, since Leaflet's attribution option takes HTML. XSS shouldn't be an issue since this is only configurable in kibana.yml right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, but now it's already in 4.1 and 4.5 FYI. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically, yes. I tend to err on the side of caution with anything like this - what if we do per visualization tilemap layers on the client in the future, this helps protect future changes from people who may not be as familiar with the code, etc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm I just checked the tags and I see that you're right. Did that actually go out in the releases? I swear I remember copy/pasting the html from the leaflet demos while testing the release candidates and it worked fine. Maybe it was added between sets of release candidates. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, it went out in the releases. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright, in that case I think we should keep it as is for now. We shouldn't change the existing API in this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also, simple html is valid markdown, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @spalger no, because the sanitize option is enabled. When I used the string
The output on the page was the literal string, html tags and all. |
||
|
||
let mapTiles = { | ||
url: 'https://otile{s}-s.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg', | ||
options: { | ||
attribution: 'Tiles by <a href="http://www.mapquest.com/">MapQuest</a> — ' + | ||
'Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, ' + | ||
'<a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>', | ||
subdomains: '1234' | ||
} | ||
url: tilemap.url, | ||
options: _.assign({}, tilemapOptions, { attribution }) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it matters, but it seems like subdomains previously defaulted to '1234' whereas now it defaults to nothing (based on the schema)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good eye, but that is actually what we want in this case. We don't use subdomains for our tile service, so the correct new default is empty. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also note: |
||
}; | ||
|
||
let markerTypes = { | ||
|
@@ -47,13 +51,13 @@ export default function MapFactory(Private) { | |
this._valueFormatter = params.valueFormatter || _.identity; | ||
this._tooltipFormatter = params.tooltipFormatter || _.identity; | ||
this._geoJson = _.get(this._chartData, 'geoJson'); | ||
this._mapZoom = params.zoom || defaultMapZoom; | ||
this._mapZoom = Math.max(Math.min(params.zoom || defaultMapZoom, tilemapOptions.maxZoom), tilemapOptions.minZoom); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WMS should reinterpret this value with its view of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In 4.5 the saved zoom was getting pulled out of the geoJson object. Did we find out params is the correct place to get it? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Bargs No, master just handles the properties differently because of a change that recently went in to make zoom levels handled through persistent state. |
||
this._mapCenter = params.center || defaultMapCenter; | ||
this._attr = params.attr || {}; | ||
|
||
let mapOptions = { | ||
minZoom: 1, | ||
maxZoom: 18, | ||
minZoom: tilemapOptions.minZoom, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did this go away? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great question. @jbudz Do you remember? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a better question might be why was it there in the first place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure why it is there in the first place, but this isn't the right PR in which to change the behavior, especially since that configuration is being passed in 4.x. I'll add it back in for now. @pickypg If you think it should be removed, feel free add an issue for it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
maxZoom: tilemapOptions.maxZoom, | ||
noWrap: true, | ||
maxBounds: L.latLngBounds([-90, -220], [90, 220]), | ||
scrollWheelZoom: false, | ||
|
@@ -277,6 +281,10 @@ export default function MapFactory(Private) { | |
|
||
// add map tiles layer, using the mapTiles object settings | ||
if (this._attr.wms && this._attr.wms.enabled) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch, fixed. |
||
_.assign(mapOptions, { | ||
minZoom: 1, | ||
maxZoom: 18 | ||
}); | ||
this._tileLayer = L.tileLayer.wms(this._attr.wms.url, this._attr.wms.options); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rather than override mapOptions, I wonder if this could go in this._attr.wms.options? It seems like this._attr.wms is where all the other wms overrides live. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't actually used by tileLayer.wms, it's used further down in L.map. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, after debugging I see now that those are two totally different option objects. |
||
} else { | ||
this._tileLayer = L.tileLayer(mapTiles.url, mapTiles.options); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's actually no need to set these as optional, keys are optional by default in Joi.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's on me, but I preferred the readability because I was mixing it with ones that were defined with
default(...)
and most did not.