Security News
CISA Brings KEV Data to GitHub
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
@globalfishingwatch/layer-composer
Advanced tools
The LayerManager orchestrates various **Layer Generators** in order to generate an entire Mapbox GL Style document that can be used with Mapbox GL and/or react-map-gl.
The LayerManager orchestrates various Layer Generators in order to generate an entire Mapbox GL Style document that can be used with Mapbox GL and/or react-map-gl.
new LayerManager(config?)
{
generators: Generator[],
glyphs: string,
sprites: string
}
Instanciates a new Layer Manager that will use the provided Layer Generators.
Draft
`layerManager.getEvent(event: GLEvent): GFWEvent`.
Converts a native Mapbox GL event into a GFW event to be used in clients (takes into account popup info, variable formatting, priority, etc).
Converts provided LayerDefinitions, using Generators, to a usable Mapbox GL JSON style object.
layerManager.getGLStyle(layers: LayerDefinition[]): { GLStyle, [promises] }
Returns the sync glStyle and an array of promises when async layers are loaded which will pass the updated GLStyle and the layer as params when layer is ready
String. Mandatory. Use constants stored in the generator.
import { Generators } from '@globalfishingwatch/layer-composer'
Generators.Types
String. Must be specified if several layers from the same generator are to be used, otherwise the type will be used as id.
new Generator(config?): void
Generators define, for a varying set of any inputs, a way to generate both GL source(s) and layer(s) for a given type of layer.
Generators each contain the styling information they need, which can take the form of a customizable bit of GL style json, or something entirely dynamic.
See Generators section below.
String. Mandatory. Defines uniquely the type of each generator, required in layer types
generator.getStyle(layer: LayerDefinition): { id: string, layers: GLLayer[], sources: GLSource[] }
Returns an object with the unique identifier and an array of sources
and layers
needed by the layers.
The Layer Manager Component is a React component that takes a ReactMapGL
component as a child and pass its props using the render props pattern.
Parameters availables:
import LayerManager, { Generators } from '@globalfishingwatch/layer-composer'
import defaultGenerators from '@globalfishingwatch/layer-composer/generators'
// optional step as common generators will be used by default
const generators = { ...defaultGenerators, { custom: new CustomGenerator()} }
<LayerManager
config={{
generators
}}
layers={[
{
type: Generators.Types.BACKGROUND,
color: '#00265c',
},
{
type: Generators.Types.BASEMAP,
id: 'satellite',
},
{
type: Generators.Types.CARTO_POLYGONS,
id: 'RFMO',
color: '#ff00ff',
},
]}
onClick={(event) => {
setState...
}}
>
{(mapStyle, loading, onClick, onHover, cursor) => {
return <ReactMapGL
mapStyle={mapStyle}
onClick={onClick}
onHover={onHover}
cursor={cursor}
...
/>
}}
</LayerManager>
There is a React hook to consume this library to get the mapStyles definition easily in react applications:
import { useLayerComposer } } from '@globalfishingwatch/react-hooks'
const { style, loading} = useLayerManager(layers, config)
To be defined
FAQs
Unknown package
The npm package @globalfishingwatch/layer-composer receives a total of 0 weekly downloads. As such, @globalfishingwatch/layer-composer popularity was classified as not popular.
We found that @globalfishingwatch/layer-composer demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CISA's KEV data is now on GitHub, offering easier access, API integration, commit history tracking, and automated updates for security teams and researchers.
Security News
Opengrep forks Semgrep to preserve open source SAST in response to controversial licensing changes.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.