Skip to content

Commit

Permalink
[Vega] Fixes problem with controls not being displayed on a map (elas…
Browse files Browse the repository at this point in the history
…tic#97373) (elastic#97433)

* add element for vegaControls

* Fix check types

* Fixed type check

Co-authored-by: Kibana Machine <[email protected]>

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
VladLasitsa and kibanamachine authored Apr 19, 2021
1 parent 58cbb76 commit cbd96ab
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class VegaBaseView {
destroy(): Promise<void>;

_$container: any;
_$controls: any;
_parser: any;
_vegaViewConfig: any;
_serviceSettings: VegaViewParams['serviceSettings'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ describe('vega_map_view/tms_raster_layer', () => {
vegaView: ({
initialize: jest.fn(),
} as unknown) as View,
vegaControls: 'element',
updateVegaView: jest.fn(),
};
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import type { LayerParameters } from './types';
export interface VegaLayerContext {
vegaView: View;
updateVegaView: (map: Map, view: View) => void;
vegaControls: any;
}

export function initVegaLayer({
id,
map: mapInstance,
context: { vegaView, updateVegaView },
context: { vegaView, vegaControls, updateVegaView },
}: LayerParameters<VegaLayerContext>) {
const vegaLayer: CustomLayerInterface = {
id,
Expand All @@ -34,7 +35,7 @@ export function initVegaLayer({
vegaContainer.style.height = mapCanvas.style.height;

mapContainer.appendChild(vegaContainer);
vegaView.initialize(vegaContainer);
vegaView.initialize(vegaContainer, vegaControls);
},
render() {
updateVegaView(mapInstance, vegaView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export class VegaMapView extends VegaBaseView {
map: mapBoxInstance,
context: {
vegaView,
vegaControls: this._$controls.get(0),
updateVegaView,
},
});
Expand Down

0 comments on commit cbd96ab

Please sign in to comment.