How to use @nextgis/ngw-kit - 4 common examples

To help you get started, we’ve selected a few @nextgis/ngw-kit 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 / ol-map-adapter / examples / main.js View on Github external
import { WebMap } from '@nextgis/webmap';
import { OlMapAdapter } from '@nextgis/ol-map-adapter';
import { NgwKit } from '@nextgis/ngw-kit';
import { QmsKit } from '@nextgis/qms-kit';

const ngwKit = new NgwKit({
  'baseUrl': "http://geonote.nextgis.com",
  'resourceId': 1,
  // 'pixelRadius': 10,
  // auth: {
  //   login: 'administrator',
  //   password: '',
  // }
})

const webMap = new WebMap({
  mapAdapter: new OlMapAdapter(),
  starterKits: [new QmsKit(), ngwKit],
});

webMap.create({
  target: 'map'
github nextgis / nextgisweb_frontend / packages / ngw-map / src / NgwMap.ts View on Github external
this._emitStatusEvent('ngw:select', null);
      return;
    }

    const pixelRadius = this.options.pixelRadius || 10;
    const center = this.getCenter();
    const zoom = this.getZoom();
    if (!center || !zoom) {
      this._emitStatusEvent('ngw:select', null);
      return;
    }
    const metresPerPixel =
      (40075016.686 * Math.abs(Math.cos((center[1] * 180) / Math.PI))) / Math.pow(2, zoom + 8);
    // FIXME: understand the circle creation function
    const radius = pixelRadius * metresPerPixel * 0.0005;
    return NgwKit.utils
      .sendIdentifyRequest(ev, {
        layers: ids,
        connector: this.connector,
        radius
      })
      .then(resp => {
        this._emitStatusEvent('ngw:select', {
          ...resp,
          resources: ids,
          sourceType: 'raster',
          event: ev
        });
        return resp;
      });
  }
}
github nextgis / nextgisweb_frontend / packages / ngw-map / src / NgwMap.ts View on Github external
async addNgwLayer(options: AddNgwLayerOptions): Promise {
    if (!options.resourceId && !options.keyname) {
      throw new Error('resourceId or keyname is required parameter to add NGW layer');
    }
    if (this.options.baseUrl || this.options.baseUrl === '') {
      try {
        const adapter = NgwKit.utils.addNgwLayer(
          options,
          this,
          this.options.baseUrl,
          this.connector
        );

        const layer = (await this.addLayer(adapter, {
          visibility: true,
          // TODO: all options into one object
          ...options,
          ...options.adapterOptions
        })) as ResourceAdapter;
        const id = layer && this.getLayerId(layer);
        if (layer && id) {
          this._ngwLayers[id] = { layer, resourceId: layer.resourceId };
github nextgis / nextgisweb_frontend / packages / ngw-map / src / utils.ts View on Github external
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
  };
}

@nextgis/ngw-kit

This library contains a plugin, a set of utilities and adapters that allow you to interact with NextGIS Web

MIT
Latest version published 27 days ago

Package Health Score

66 / 100
Full package analysis