Module @nextgis/ngw-connector

NgwConnector

size version

A lightweight HTTP client optimized for use with NextGIS Web API.

Make sure CORS is registered in the NextGIS Web settings to be able to send requests.

Simply download and include with a script tag, NgwConnector will be registered as a global variable.

<script src="../lib/ngw-connector.global.js"></script>

<script>
var ngwConnector = new NgwConnector({
baseUrl: 'https://demo.nextgis.com',
});
</script>

unpkg

<script src="https://unpkg.com/@nextgis/ngw-connector"></script>

jsdelivr

<script src="https://cdn.jsdelivr.net/npm/@nextgis/ngw-connector"></script>

We recommend linking to a specific version number /ngw-connector@[version]

npm install @nextgis/ngw-connector

If you plan to use this library in a TypeScript project, it's recommended to install TypeScript declaration files for NextGIS Web by using the @nextgis/ngw-types-loader tool.

Run the following command to download the latest TypeScript declaration files:

npx @nextgis/ngw-types-loader

This will download the declaration file from the default NextGIS Web instance (https://demo.nextgis.com) and update your tsconfig.json to include it.

If you are using a custom NextGIS Web deployment, you can specify the URL:

npx @nextgis/ngw-types-loader https://your-custom-ngw-url.com

After running the tool, ensure that your tsconfig.json includes the downloaded file:

{
"include": [
"./nextgisweb.d.ts"
]
}

For more details, refer to the NGW Types Loader.

import NgwConnector from '@nextgis/ngw-connector';

const ngwConnector = new NgwConnector({
baseUrl: 'https://demo.nextgis.com',
// auth: {login, password}
});

ngwConnector
.route('resource.item', { id: 485 })
.get()
.then((data) => {
console.log(data);
});

ngwConnector.route('resource.collection').patch({ json: RESOURCE });
ngwConnector.route('feature_layer.feature.collection', { id }).patch({
json: ITEMS,
query: {
srs: 4326,
geom_format: 'geojson',
},
});
ngwConnector
.route('feature_layer.feature.item', { id, fid })
.put({ json: ITEM });
ngwConnector.route('feature_layer.feature.item', { id, fid }).delete();

// Shortcuts methods to find resources
ngwConnector.getResource(2011); // by id
ngwConnector.getResource('keyname'); // by keyname

ngwConnector.getResources({ cls: 'vector_layer', parent__id: 0 }); // find resources by partial resource params
ngwConnector.getResource({ display_name: 'My layer', parent__id: 0 }); // get first

Check out the API Documentation

NextGIS Web API Doc

ngwConnector.get(request_name, request_options, arguments);

request_options

API request names

Need to fix a bug or add a feature to @nextgis/ngw-connector? We provide custom development and support for this software. Contact us to discuss options!

http://nextgis.com

Index

Classes

Interfaces

Type Aliases