0.0.9 • Published 6 months ago

@icgcat/layer-types v0.0.9

Weekly downloads
-
License
BSD-3-Clause
Repository
-
Last release
6 months ago

License Version LinkedIn

@icgcat/layer-types

Introduction

@icgcat/layer-types is a JavaScript package that simplifies integrating geospatial data into a Map library, supporting FlatGeobuf (FGB), WMS, PMTiles, and Raster COG file formats. It handles vector and raster tiles, offering easy customization for styling and layer rendering.


Installation

To install the package, use npm or yarn:

npm install @icgcat/layer-types

Usage

Import and Basic Example

Here's how to use the stats functions in your application:

<script>

import { getSrcLayerFromFGB } from '@layer-types/layer-types';
const fgbLayer = getSrcLayerFromFGB("https://tilemaps.icgc.cat/vector/fgb/arees_hidrogeologiques_aquifers_vigent.fgb", 'aquifers_fgb');

</script>

Component Functions

getSrcLayerFromFGB(url, idLayer) ⇒ Promise.<Object>

Fetches a FlatGeobuf (FGB) file and converts its contents into a Map layer, based on the geometry type of the features within the file. The layer is created using the provided layer ID. The resulting layer can be used in a MapLibre map.

Kind: global function
Returns: Promise.<Object> - A promise that resolves to an object containing sourceContent and layerContent.
Throws:

  • Error Throws an error if the geometry type cannot be determined from the features in the file.
ParamTypeDescription
urlstringThe URL of the FlatGeobuf (FGB) file to be fetched.
idLayerstringThe ID to be used for the source and layer in the map.

Example

const fgbLayer = await getSrcLayerFromFGB("https://example.com/data.fgb", "myLayer");

getSrcLayerFromWMS(url, idLayer) ⇒ Object

Creates a Map layer from a WMS (Web Map Service) source using the provided URL and layer ID.

Kind: global function
Returns: Object - An object containing sourceContent and layerContent.

ParamTypeDescription
urlstringBase URL of the WMS service, which may include a placeholder for {bbox-epsg-3857} that will be replaced dynamically.
idLayerstringThe ID to be used for the source and layer in the map.

Example

const wmsLayer = getSrcLayerFromWMS("https://example.com/wms?service=WMS&request=GetMap&version=1.1.1&layers={layer}&format=image/png&transparent=true&width=512&height=512&srs=EPSG:3857&bbox={bbox-epsg-3857}", "myWmsLayer");

getSrcLayerFromPMTiles(url, idLayer) ⇒ Object

Converts a PMTiles file into a Map layer based on its content type (vector or raster). Supports both vector and raster tiles within the PMTiles format.

Kind: global function
Returns: Object - An object containing sourceContent and layerContent.

ParamTypeDescription
urlstringURL of the PMTiles file to be fetched.
idLayerstringThe ID to be used for the source and layers in the map.

Example

const pmtilesLayer = await getSrcLayerFromPMTiles("https://example.com/tiles.pmtiles", "myPmtilesLayer");

getSrcLayerFromCOG(url, idLayer) ⇒ Object

Converts a Cloud Optimized GeoTIFF (COG) into a Map raster layer. Supports optional customization of layer properties using the provided idLayer.

Kind: global function
Returns: Object - An object containing sourceContent and layerContent.

ParamTypeDescription
urlstringURL of the Raster COG file to be fetched.
idLayerstringThe ID to be used for the source and layer in the map.

Example

const cogLayer = getSrcLayerFromCOG("https://example.com/image.tif", "myCogLayer");

Dependencies

@icgc/stats integrates the following libraries:

  • pmtiles
  • flatgeobuf
  • cogProtocol
  • maplibre-gl

Developed by:

License

This project is licensed under the MIT License.

0.0.9

6 months ago

0.0.8

9 months ago

0.0.7-h

9 months ago

0.0.7-g

9 months ago

0.0.7-f

9 months ago

0.0.7-e

9 months ago

0.0.7-d

9 months ago

0.0.7-c

9 months ago

0.0.7-b

9 months ago

0.0.7-a

9 months ago

0.0.7

9 months ago

0.0.6

9 months ago

0.0.5

9 months ago

0.0.4-b

9 months ago

0.0.4-a

9 months ago

0.0.4

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago