4.1. No map. NgwKit

December 9, 2021 ยท View on GitHub

Theory

The @nextgis/new-kit library provides a set of utilities to simplify interaction with the vector layers data in NGW. It also provides a set of tools for implementing various complex mechanics that require a sequence of more than one query or translate data into a convenient format.

Documentation

To work with this library, you will need the @nextgis/new-connector library.

import NgwConnector from "@nextgis/ngw-connector";
import { fetchNgwLayerItems } from "@nextgis/ngw-kit";

const connector = new NgwConnector({ baseUrl });

fetchNgwLayerItems({
  connector,
  resourceId,
  // it is good practice to only ask for fields that will be used
  fields: ["NAME"],
  geom: false,
  filters: [["NAME", "eq", "Subway"]],
  limit: 10,
  cache: true,
});

More examples

Practice

  • take a good look at the functions available in this library. Most likely, if you need some of them when developing your application;
  • practice with the vector layer filter;
  • find a way to upload data immediately in GeoJSON format;
  • ๐Ÿค“ rewrite the example so that data from resource 1733 is loaded in parallel with several requests at once.

To run this example, you need to execute these commands in the terminal:

npm i
npm start

Look for the script output in the terminal.

LAUNCH in the codesandbox.io.

BACK TO CONTENT