-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Fix/map zoom #6835
Fix/map zoom #6835
Changes from 4 commits
e6dbd8c
9ac4961
d7b3cb5
ad62b60
5c7ee7d
6cfe38d
bff8276
3366e81
bd4b5c6
dfdf713
b3bc6c8
ff97284
fd30551
cb758cc
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 |
---|---|---|
|
@@ -11,6 +11,30 @@ export default function TileMapVisType(Private, getAppState, courier, config) { | |
const Schemas = Private(VisSchemasProvider); | ||
const geoJsonConverter = Private(AggResponseGeoJsonGeoJsonProvider); | ||
|
||
// zoomPrecision maps event.zoom to a geohash precision value | ||
// event.limit is the configurable max geohash precision | ||
// default max precision is 7, configurable up to 12 | ||
const zoomPrecision = { | ||
1: 2, | ||
2: 2, | ||
3: 2, | ||
4: 3, | ||
5: 3, | ||
6: 4, | ||
7: 4, | ||
8: 5, | ||
9: 5, | ||
10: 6, | ||
11: 6, | ||
12: 7, | ||
13: 7, | ||
14: 8, | ||
15: 9, | ||
16: 10, | ||
17: 11, | ||
18: 12 | ||
}; | ||
|
||
return new VislibVisType({ | ||
name: 'tile_map', | ||
title: 'Tile map', | ||
|
@@ -27,6 +51,8 @@ export default function TileMapVisType(Private, getAppState, courier, config) { | |
heatRadius: 25, | ||
heatBlur: 15, | ||
heatNormalizeData: true, | ||
mapZoom: 2, | ||
mapCenter: [15, 5], | ||
wms: config.get('visualization:tileMap:WMSdefaults') | ||
}, | ||
mapTypes: ['Scaled Circle Markers', 'Shaded Circle Markers', 'Shaded Geohash Grid', 'Heatmap'], | ||
|
@@ -46,49 +72,40 @@ export default function TileMapVisType(Private, getAppState, courier, config) { | |
|
||
pushFilter(filter, false, indexPatternName); | ||
}, | ||
mapMoveEnd: function (event) { | ||
mapMoveEnd: function (event, uiState) { | ||
const mapPrecision = zoomPrecision[event.zoom]; | ||
uiState.set('vis.params.mapCenter', event.center); | ||
uiState.set('vis.params.mapZoom', event.zoom); | ||
uiState.set('vis.params.mapPrecision', mapPrecision); | ||
|
||
const agg = _.get(event, 'chart.geohashGridAgg'); | ||
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 not just As it is, if 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. Will change. |
||
if (!agg) return; | ||
|
||
agg.params.mapZoom = event.zoom; | ||
agg.params.mapCenter = [event.center.lat, event.center.lng]; | ||
agg.params.mapCenter = event.center; | ||
|
||
const editableVis = agg.vis.getEditableVis(); | ||
if (!editableVis) return; | ||
|
||
// editableVis.params.mapCenter = event.center; | ||
// editableVis.params.mapZoom = event.zoom; | ||
|
||
const editableAgg = editableVis.aggs.byId[agg.id]; | ||
if (editableAgg) { | ||
editableAgg.params.mapZoom = event.zoom; | ||
editableAgg.params.mapCenter = [event.center.lat, event.center.lng]; | ||
editableAgg.params.mapCenter = event.center; | ||
editableAgg.params.mapPrecision = mapPrecision; | ||
} | ||
}, | ||
mapZoomEnd: function (event) { | ||
mapZoomEnd: function (event, uiState) { | ||
const agg = _.get(event, 'chart.geohashGridAgg'); | ||
if (!agg || !agg.params.autoPrecision) return; | ||
const mapPrecision = zoomPrecision[event.zoom]; | ||
uiState.set('vis.params.mapZoom', event.zoom); | ||
uiState.set('vis.params.mapPrecision', mapPrecision); | ||
|
||
// zoomPrecision maps event.zoom to a geohash precision value | ||
// event.limit is the configurable max geohash precision | ||
// default max precision is 7, configurable up to 12 | ||
const zoomPrecision = { | ||
1: 2, | ||
2: 2, | ||
3: 2, | ||
4: 3, | ||
5: 3, | ||
6: 4, | ||
7: 4, | ||
8: 5, | ||
9: 5, | ||
10: 6, | ||
11: 6, | ||
12: 7, | ||
13: 7, | ||
14: 8, | ||
15: 9, | ||
16: 10, | ||
17: 11, | ||
18: 12 | ||
}; | ||
if (!agg) return; | ||
agg.params.mapZoom = event.zoom; | ||
|
||
if (!agg || !agg.params.autoPrecision) return; | ||
|
||
const precision = config.get('visualization:tileMap:maxPrecision'); | ||
agg.params.precision = Math.min(zoomPrecision[event.zoom], precision); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,30 @@ export default function GeoHashAggDefinition(Private, config) { | |
var BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); | ||
var defaultPrecision = 2; | ||
|
||
// zoomPrecision maps event.zoom to a geohash precision value | ||
// event.limit is the configurable max geohash precision | ||
// default max precision is 7, configurable up to 12 | ||
const zoomPrecision = { | ||
1: 2, | ||
2: 2, | ||
3: 2, | ||
4: 3, | ||
5: 3, | ||
6: 4, | ||
7: 4, | ||
8: 5, | ||
9: 5, | ||
10: 6, | ||
11: 6, | ||
12: 7, | ||
13: 7, | ||
14: 8, | ||
15: 9, | ||
16: 10, | ||
17: 11, | ||
18: 12 | ||
}; | ||
|
||
function getPrecision(precision) { | ||
var maxPrecision = _.parseInt(config.get('visualization:tileMap:maxPrecision')); | ||
|
||
|
@@ -45,19 +69,17 @@ export default function GeoHashAggDefinition(Private, config) { | |
}, | ||
{ | ||
name: 'precision', | ||
default: defaultPrecision, | ||
editor: precisionTemplate, | ||
controller: function ($scope) { | ||
$scope.$watchMulti([ | ||
'agg.params.autoPrecision', | ||
'outputAgg.params.precision' | ||
], function (cur, prev) { | ||
if (cur[1]) $scope.agg.params.precision = cur[1]; | ||
}); | ||
}, | ||
deserialize: getPrecision, | ||
write: function (aggConfig, output) { | ||
output.params.precision = getPrecision(aggConfig.params.precision); | ||
let currZoom = aggConfig.vis.params.mapZoom; | ||
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 a fan of this function. I have to figure out whether the 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 the proper solution is to fix the dashboard and ensure the vis gets it uiState on the dashboard. |
||
if (aggConfig.params.mapZoom || aggConfig.vis.uiState) { // First iteration | ||
currZoom = aggConfig.vis.uiState ? aggConfig.vis.uiState.get('vis.params.mapZoom') : aggConfig.params.mapZoom; | ||
} | ||
const autoPrecisionVal = zoomPrecision[currZoom]; | ||
output.params.precision = aggConfig.params.autoPrecision ? autoPrecisionVal : getPrecision(aggConfig.params.precision); | ||
} | ||
} | ||
] | ||
|
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.
Why vis.params? these can just be
'mapCenter'
,'mapZoom'
, and'mapPrecision'
I think. Otherwise it's confusing.