Skip to content

Commit

Permalink
[Cleanup] finally have it all working, though very ugly
Browse files Browse the repository at this point in the history
  • Loading branch information
panda01 committed Apr 13, 2016
1 parent d7b3cb5 commit ad62b60
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 20 deletions.
8 changes: 7 additions & 1 deletion src/plugins/kbn_vislib_vis_types/public/tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,13 @@ export default function TileMapVisType(Private, getAppState, courier, config) {
},
mapZoomEnd: function (event, uiState) {
const agg = _.get(event, 'chart.geohashGridAgg');
// this could be a problem, conditional on autoPrecision
const mapPrecision = zoomPrecision[event.zoom];
uiState.set('vis.params.mapZoom', event.zoom);
uiState.set('vis.params.mapPrecision', mapPrecision);

if (!agg) return;
agg.params.mapZoom = event.zoom;

if (!agg || !agg.params.autoPrecision) return;

const precision = config.get('visualization:tileMap:maxPrecision');
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_response/geo_json/geo_json.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export default function TileMapConverterFn(Private, timefilter, $compile, $rootS
properties: {
min: _.min(values),
max: _.max(values),
zoom: _.get(geoAgg, 'params.mapZoom') || vis.uiState.get('vis.params.mapZoom'),
center: _.get(geoAgg, 'params.mapCenter') || vis.uiState.get('vis.params.mapCenter')
zoom: _.get(geoAgg, 'params.mapZoom'),
center: _.get(geoAgg, 'params.mapCenter')
}
}
};
Expand Down
23 changes: 6 additions & 17 deletions src/ui/public/agg_types/buckets/geo_hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,28 +69,17 @@ export default function GeoHashAggDefinition(Private, config) {
},
{
name: 'precision',
default: defaultPrecision,
editor: precisionTemplate,
controller: function ($scope) {
$scope.$watchGroup([
'agg.params.mapZoom',
'agg.params.autoPrecision'],
function (curr, prev) {
const zoom = curr[0];
const autoPrecision = curr[1];
if (autoPrecision) {
$scope.agg.params.precision = zoomPrecision[zoom];
}
});
$scope.$watch('agg.params.precision', function(precision) {
// $scope.uiState.set('mapPrecision', preci
});

$scope.agg.params.mapZoom = $scope.uiState.get('vis.params.mapZoom');
},
deserialize: getPrecision,
write: function (aggConfig, output) {
output.params.precision = getPrecision(aggConfig.params.precision);
let currZoom = aggConfig.vis.params.mapZoom;
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);
}
}
]
Expand Down

0 comments on commit ad62b60

Please sign in to comment.