How to use @nextgis/utils - 6 common examples

To help you get started, we’ve selected a few @nextgis/utils examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nextgis / nextgisweb_frontend / packages / qms-kit / src / utility.ts View on Github external
return new Promise((resolve, reject) => {
    const xmlHttp = new XMLHttpRequest();
    xmlHttp.onreadystatechange = () => {
      if (xmlHttp.readyState === 4 && xmlHttp.status === 200) {
        if (xmlHttp.responseText) {
          try {
            resolve(JSON.parse(xmlHttp.responseText));
          } catch (er) {
            reject(er);
          }
        }
      }
    };
    xmlHttp.open('GET', fixUrlStr(url), true); // true for asynchronous
    xmlHttp.send();
  });
}
github nextgis / nextgisweb_frontend / packages / ngw-map / src / utils.ts View on Github external
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
  };
}
github nextgis / nextgisweb_frontend / packages / ngw-map / src / NgwMap.ts View on Github external
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();
    });
  }
github nextgis / nextgisweb_frontend / packages / webmap / src / BaseWebMap.ts View on Github external
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;
  }
github nextgis / nextgisweb_frontend / packages / webmap / src / BaseWebMap.ts View on Github external
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);
    }
  }
github nextgis / nextgisweb_frontend / packages / ngw-kit / src / WebMapLayerAdapter.ts View on Github external
private _updateItemsParams(item: TreeGroup | TreeLayer, webMap: WebMap, data: ResourceItem) {
    if (item) {
      if (item.item_type === 'group' || item.item_type === 'root') {
        if (item.children) {
          item.children = item.children.map(x => this._updateItemsParams(x, webMap, data));
        }
        if (item.item_type === 'root') {
          item.display_name = data.resource.display_name;
        }
      } else if (item.item_type === 'layer') {
        const url = fixUrlStr(this.options.baseUrl + '/api/component/render/image');
        const resourceId = item.layer_style_id;
        item.url = url;
        item.resourceId = resourceId;
        item.updateWmsParams = params => updateWmsParams(params, resourceId);
        item = {
          ...item,
          ...getLayerAdapterOptions(
            {
              adapter: item.layer_adapter.toUpperCase() as NgwLayerAdapterType,
              resourceId
            },
            webMap,
            this.options.baseUrl
          )
        };
      }

@nextgis/utils

Common development tools

MIT
Latest version published 16 days ago

Package Health Score

69 / 100
Full package analysis

Popular @nextgis/utils functions