4.2. NgwMap. AddNgwLayer
March 20, 2024 ยท View on GitHub
Theory
To add resources from NGW after the map has already been created, there is a very convenient addNgwLayer method.
// add raster layer resourceId is the style of 7154 layer
ngwMap.addNgwLayer({ resource: 7159 });
// add vector data from layer GEOJSON source
ngwMap.addNgwLayer({
fit: true,
resourceId: 7154,
adapter: "GEOJSON",
adapterOptions: { paint: { color: "red", fill: false, weight: 4 } },
});
The options for adding a layer will be the same as in the example 4_1_ngwmap_resources. The behavior of the layer is equal to the example with the addLayer method 3_1_layers_geojson.
Practice
To run this example, you need to execute these commands in the terminal:
npm i
npm start
Open http://localhost:8080.
LAUNCH in the codesandbox.io.