How to use the @nextgis/ngw-kit.utils function in @nextgis/ngw-kit

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 / 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 };

@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 12 days ago

Package Health Score

69 / 100
Full package analysis