Skip to content

Commit 5b8e62f

Browse files
committed
Fix some comments
1 parent 9e1e3d5 commit 5b8e62f

2 files changed

Lines changed: 27 additions & 27 deletions

File tree

src/plugins/vis_type_vega/public/vega_view/vega_map_view/utils/vsi_helper.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Public License, v 1.
77
*/
88

9-
// @ts-ignore
9+
// @ts-expect-error
1010
// eslint-disable-next-line import/no-extraneous-dependencies
1111
import Vsi from 'vega-spec-injector';
1212

src/plugins/vis_type_vega/public/vega_view/vega_map_view/view.ts

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,34 @@ import {
2424

2525
import { validateZoomSettings, injectMapPropsIntoSpec } from './utils';
2626

27-
// @ts-ignore
27+
// @ts-expect-error
2828
import { vega } from '../../lib/vega';
2929

3030
import './vega_map_view.scss';
3131

32+
async function updateVegaView(mapBoxInstance: Map, vegaView: vega.View) {
33+
const mapCanvas = mapBoxInstance.getCanvas();
34+
const { lat, lng } = mapBoxInstance.getCenter();
35+
let shouldRender = false;
36+
37+
const sendSignal = (sig: string, value: any) => {
38+
if (vegaView.signal(sig) !== value) {
39+
vegaView.signal(sig, value);
40+
shouldRender = true;
41+
}
42+
};
43+
44+
sendSignal('width', mapCanvas.clientWidth);
45+
sendSignal('height', mapCanvas.clientHeight);
46+
sendSignal('latitude', lat);
47+
sendSignal('longitude', lng);
48+
sendSignal('zoom', mapBoxInstance.getZoom());
49+
50+
if (shouldRender) {
51+
await vegaView.runAsync();
52+
}
53+
}
54+
3255
export class VegaMapView extends VegaBaseView {
3356
private mapServiceSettings: MapServiceSettings = getMapServiceSettings();
3457
private mapStyle = this.getMapStyle();
@@ -110,29 +133,6 @@ export class VegaMapView extends VegaBaseView {
110133
mapBoxInstance.once('load', initMapComponents);
111134
}
112135

113-
private async updateVegaView(mapBoxInstance: Map, vegaView: vega.View) {
114-
const mapCanvas = mapBoxInstance.getCanvas();
115-
const { lat, lng } = mapBoxInstance.getCenter();
116-
let shouldRender = false;
117-
118-
const sendSignal = (sig: string, value: any) => {
119-
if (vegaView.signal(sig) !== value) {
120-
vegaView.signal(sig, value);
121-
shouldRender = true;
122-
}
123-
};
124-
125-
sendSignal('width', mapCanvas.clientWidth);
126-
sendSignal('height', mapCanvas.clientHeight);
127-
sendSignal('latitude', lat);
128-
sendSignal('longitude', lng);
129-
sendSignal('zoom', mapBoxInstance.getZoom());
130-
131-
if (shouldRender) {
132-
await vegaView.runAsync();
133-
}
134-
}
135-
136136
private initControls(mapBoxInstance: Map) {
137137
if (this.shouldShowZoomControl) {
138138
mapBoxInstance.addControl(new NavigationControl({ showCompass: false }), 'top-left');
@@ -162,12 +162,12 @@ export class VegaMapView extends VegaBaseView {
162162
map: mapBoxInstance,
163163
context: {
164164
vegaView,
165-
updateVegaView: this.updateVegaView,
165+
updateVegaView,
166166
},
167167
});
168168
}
169169

170-
public async _initViewCustomizations() {
170+
protected async _initViewCustomizations() {
171171
const vegaView = new vega.View(
172172
vega.parse(injectMapPropsIntoSpec(this._parser.spec)),
173173
this._vegaViewConfig

0 commit comments

Comments
 (0)