/
VueNgwMapBase.ts
59 lines (50 loc) · 1.51 KB
/
VueNgwMapBase.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import Vue, { VNode, VNodeData, CreateElement } from 'vue';
import { Prop } from 'vue-property-decorator';
import Component from 'vue-class-component';
import NgwMap, { NgwMapOptions, MapAdapter } from '@nextgis/ngw-map';
import NgwConnector from '@nextgis/ngw-connector';
@Component
export class VueNgwMapBase extends Vue {
@Prop({ type: Object }) mapAdapter!: MapAdapter;
@Prop({ type: Boolean }) fullFilling!: boolean;
@Prop({ type: NgwConnector }) connector!: NgwConnector;
@Prop({ type: String }) baseUrl!: string;
@Prop({ type: Number }) qmsId!: string;
@Prop({ type: String }) webMapId!: string;
@Prop({ type: Object }) mapOptions!: NgwMapOptions;
name = 'vue-ngw-map';
ngwMap!: NgwMap;
ready = false;
mounted() {
this._setNgwMap();
}
beforeDestroy() {
this.ngwMap.destroy();
}
render(h: CreateElement): VNode {
const staticStyle: { [param: string]: string } = {
zIndex: '0'
};
if (this.fullFilling) {
staticStyle.width = '100%';
staticStyle.height = '100%';
}
const data: VNodeData = {
staticClass: 'vue-ngw-map',
staticStyle,
// 'class': this.classes,
attrs: { 'data-app': true }
// domProps: { id: this.id }
};
return this.ready ? h('div', data, this.$slots.default) : h('div', data);
}
private _setNgwMap() {
this.ngwMap = new NgwMap(this.mapAdapter, {
...this.$props,
...this.mapOptions,
target: this.$el as HTMLElement
});
this.ready = true;
}
}
export default VueNgwMapBase;