-
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 8 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 |
---|---|---|
|
@@ -55,6 +55,12 @@ uiModules | |
// create child ui state from the savedObj | ||
const uiState = panelConfig.uiState || {}; | ||
$scope.uiState = $scope.parentUiState.createChild(getPanelId(panelConfig.panel), uiState, true); | ||
if (panelConfig.uiState) { | ||
panelConfig.uiState = $scope.uiState; | ||
} | ||
if (panelConfig.setUiState) { | ||
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. See my note in |
||
panelConfig.setUiState($scope.uiState); | ||
} | ||
|
||
$scope.filter = function (field, value, operator) { | ||
const index = $scope.savedObj.searchSource.get('index').id; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,6 +6,30 @@ export default function GeoHashAggDefinition(Private, config) { | |
let BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider); | ||
let 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) { | ||
let maxPrecision = _.parseInt(config.get('visualization:tileMap:maxPrecision')); | ||
|
||
|
@@ -45,19 +69,18 @@ export default function GeoHashAggDefinition(Private, config) { | |
}, | ||
{ | ||
name: 'precision', | ||
default: defaultPrecision, | ||
editor: precisionTemplate, | ||
deserialize: getPrecision, | ||
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 = null; | ||
if (aggConfig.params.mapZoom || aggConfig.vis.hasUiState()) { // First iteration | ||
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 a fan of all of this |
||
currZoom = aggConfig.vis.hasUiState() ? aggConfig.vis.uiStateVal('mapZoom') : aggConfig.params.mapZoom; | ||
} | ||
currZoom = currZoom || aggConfig.vis.params.mapZoom; | ||
const autoPrecisionVal = zoomPrecision[currZoom]; | ||
output.params.precision = aggConfig.params.autoPrecision ? autoPrecisionVal : getPrecision(aggConfig.params.precision); | ||
} | ||
} | ||
] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ export default function VisFactory(Notifier, Private) { | |
location: 'Vis' | ||
}); | ||
|
||
function Vis(indexPattern, state) { | ||
function Vis(indexPattern, state, uiState) { | ||
state = state || {}; | ||
|
||
if (_.isString(state)) { | ||
|
@@ -24,6 +24,7 @@ export default function VisFactory(Notifier, Private) { | |
|
||
// http://aphyr.com/data/posts/317/state.gif | ||
this.setState(state); | ||
this.__uiState = uiState; | ||
} | ||
|
||
Vis.convertOldState = function (type, oldState) { | ||
|
@@ -125,5 +126,24 @@ export default function VisFactory(Notifier, Private) { | |
}); | ||
}; | ||
|
||
Vis.prototype.hasUiState = function () { | ||
return !!this.__uiState; | ||
}; | ||
Vis.prototype.setUiState = function (uiState) { | ||
this.__uiState = uiState; | ||
}; | ||
Vis.prototype.getUiState = function () { | ||
return this.__uiState; | ||
}; | ||
Vis.prototype.uiStateVal = function(key, val) { | ||
if (this.hasUiState()) { | ||
if (_.isUndefined(val)) { | ||
return this.__uiState.get(key); | ||
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. You never check that 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, I will change. |
||
} | ||
return this.__uiState.set(key, val); | ||
} | ||
return val; | ||
}; | ||
|
||
return Vis; | ||
}; |
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.
I'm not a fan of there being a setter here. There are other properties that are consumed off of the passed in
$scope
, why not do the same with the uiState as well? It'll simplify the use inpanel.js
as well.