-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from Vizzuality/feature/add-marine-biodiversi…
…ty-layer Feature/add marine biodiversity layer
- Loading branch information
Showing
29 changed files
with
767 additions
and
566 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
lts/erbium | ||
12.21.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
remote_theme: pmarsceill/just-the-docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Layers update flow. | ||
|
||
Adding layers to the project is just a matter of following some steps to create the proper entry in the `layersConfig` object. This config will be consumed by the code that will take care of creating and adding the layers to the globe (that is the `createLayer` and `addLayerToMap` functions on `utils/layer-manager-utils`). | ||
In order to add a layer to the config we need to create some `constants` that will build up the needed data structure. | ||
Lets explain the steps with an example on how we would add a layer with fishes priority data 🐟 🐠 | ||
|
||
- Create a new layer slug on the `constants/layers-slugs` for the layer to be added. This `slug` needs to be shared with the science team people of the project in order to add layer metadata to the metadata service. | ||
|
||
```js | ||
export const FISHES_PRIORITY = 'fishes-priority'; | ||
``` | ||
- `import` the newly created slugs into `constants/layers-urls` and asign it the url string (inside the `LAYERS_URLS` object) from the ArcGIS online service. | ||
```js | ||
import { | ||
FISHES_PRIORITY | ||
} from 'constants/layers-slugs'; | ||
export const LAYERS_URLS = { | ||
[FISHES_PRIORITY]: 'https://tiles.arcgis.com/tiles/arcgis/rest/services/Global_marine_fish_prioritisation_TL/MapServer' | ||
} | ||
``` | ||
- First of all we need to know if the type of layer we want to add is already present on the `LAYER_TYPES` constant on the `constants/layers-config` file. | ||
Find [in this link](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html) the list of the available layer types on the ArcGIS js API. | ||
These are the layer types we are currently using in the platform: | ||
```js | ||
const LAYER_TYPES = { | ||
FEATURE_LAYER: 'FeatureLayer', | ||
TILE_LAYER: 'TileLayer', | ||
VECTOR_TILE_LAYER: 'VectorTileLayer' | ||
} | ||
``` | ||
- Now we are ready to add the layer to the `layerConfig` on `constants/layers-config`. We first need to `import` the layer slug and layers urls to then create the entry for the layer on the config object. | ||
```js | ||
import { | ||
FISHES_PRIORITY | ||
} from 'constants/layers-slugs'; | ||
export const layersConfig = { | ||
[FISHES_PRIORITY]: { | ||
title: FISHES_PRIORITY, | ||
slug: FISHES_PRIORITY, | ||
type: LAYER_TYPES.TILE_LAYER, | ||
url: LAYERS_URLS[FISHES_PRIORITY], | ||
bbox: null | ||
} | ||
} | ||
``` | ||
- Note that there's a `bbox` (bounding box) key on the layer object. This field serves to tell the app that this layer is restricted to a certain area of the globe. By providing a set of coordinates to this `bbox` whenever the layer is added to the map the camera will _travel_ to the specified location. Serve as an example the _hummingbirds rarity_ layer config , restricted to the Americas: | ||
```js | ||
[HUMMINGBIRDS_RARITY]: { | ||
title: HUMMINGBIRDS_RARITY, | ||
slug: HUMMINGBIRDS_RARITY, | ||
type: LAYER_TYPES.TILE_LAYER, | ||
url: LAYERS_URLS[HUMMINGBIRDS_RARITY], | ||
bbox: [-164,-40,-35,56] | ||
} | ||
``` | ||
- The last step for a layer to be ready to be used on the platform is to add the needed configuration to be consumed by the `legend` component. Different legend configurations are created depending on the category of the layer (_biodiversity_, _human pressures_ or _protected areas_), and those are stored into the associated file in the `constants` folder. In this case, fishes priority layer, the legend config to be updated is located on the `constants/biodiversity-layers-constants` file. | ||
```js | ||
import { | ||
FISHES_PRIORITY | ||
} from 'constants/layers-slugs'; | ||
export const legendConfigs = { | ||
[FISHES_PRIORITY]: { | ||
...defaultGradientConfig, | ||
title: "Fishes priority" | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/components/biodiversity-sidebar-card/biodiversity-sidebar-card-component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/biodiversity-sidebar-card/biodiversity-sidebar-card-hooks.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/human-impact-layers/human-impact-layers-component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/human-impact-sidebar-card/human-impact-sidebar-card-component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/priority-places-polygons-layer/priority-places-polygons-layer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/components/protected-areas-sidebar-card/protected-areas-sidebar-card-component.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.