Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function prepareWebMapOptions(
mapAdapter: MapAdapter,
options: NgwMapOptions
) {
const kits: StarterKit[] = [new QmsKit()];
if (!options.connector && options.baseUrl) {
options.connector = new NgwConnector({
baseUrl: options.baseUrl,
auth: options.auth
});
} else if (options.connector) {
options.baseUrl = options.connector.options.baseUrl;
}
const opt: NgwMapOptions = deepmerge(OPTIONS, options);
if (opt.connector) {
kits.push(
new NgwKit({
connector: opt.connector,
auth: opt.auth,
identification: opt.identification
})
);
}
return {
mapAdapter,
starterKits: kits,
runtimeParams: options.runtimeParams
};
}
constructor(mapAdapter: MapAdapter, options: NgwMapOptions & O) {
super(prepareWebMapOptions(mapAdapter, options));
if (options.connector) {
this.connector = options.connector;
}
this.options = deepmerge(OPTIONS, options);
this._createWebMap().then(() => {
const container = this.getContainer();
if (container) {
container.classList.add('ngw-map-container');
}
this._addControls();
});
}
async create(options?: MapOptions): Promise {
if (!this.getEventStatus('create')) {
this.options = deepmerge(OPTIONS || {}, options);
await this._setInitMapState(this.mapState);
await this._setupMap();
this._emitStatusEvent('create', this);
}
return this;
}
constructor(appOptions: AppOptions) {
this.mapAdapter = appOptions.mapAdapter;
this._starterKits = appOptions.starterKits || [];
if (appOptions.mapOptions) {
this.options = deepmerge(OPTIONS || {}, appOptions.mapOptions);
}
if (appOptions.runtimeParams) {
this.runtimeParams = appOptions.runtimeParams;
}
this._addEventsListeners();
if (appOptions.create) {
this.create(this.options);
}
}