-
Notifications
You must be signed in to change notification settings - Fork 32
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 #949 from geonetwork/use-geoespatial-sdk-for-maps
Use geospatial-sdk for maps
- Loading branch information
Showing
113 changed files
with
2,038 additions
and
3,593 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@import 'ol/ol.css'; |
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
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
apps/webcomponents/src/app/components/gn-map-viewer/gn-map-viewer.component.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
--- | ||
outline: deep | ||
--- | ||
|
||
# Interactive maps | ||
|
||
GeoNetwork-UI relies on the [geospatial-sdk](https://github.com/camptocamp/geospatial-sdk) library to render maps. This library works by taking in a Map Context ([see the model here](https://github.com/camptocamp/geospatial-sdk/blob/main/packages/core/lib/model/map-context.ts)) describing the layers and the view of the map to be shown. | ||
|
||
Two components are present in GeoNetwork-UI to render a map using a context. | ||
|
||
## `MapContainerComponent` | ||
|
||
This component simply takes a map context as input and will render it. Everytime the map context changes, the map is updated accordingly. | ||
|
||
This component also offers the following events: `mapClick`, `featuresClicked`, `featuresHovered`. | ||
|
||
```ts | ||
import { MapContainerComponent } from '@geonetwork-ui/ui/map' | ||
``` | ||
|
||
```html | ||
<gn-ui-map-container | ||
[context]="mapContext" | ||
(featuresClick)="handleFeaturesClicked($event)" | ||
></gn-ui-map-container> | ||
``` | ||
|
||
There are a couple of injection tokens that can be used to specify some map options: | ||
|
||
- `BASEMAP_LAYERS`: this allows specifying layers that will be added in the background of the map, regardless of the layers in the context; note that there is always a default background tile layer so that the map shown is never empty; this default background layer can be disabled by setting the `DO_NOT_USE_DEFAULT_BASEMAP` token to `true` | ||
- `MAP_VIEW_CONSTRAINTS`: this allows specifying `maxZoom` and `maxExtent` options that will be applied regardless of the map context | ||
|
||
## `MapStateContainerComponent` | ||
|
||
This component is connected to a map state accessible through the `MapFacade` class. This allows changing the context used in the map from anywhere in the application, as well as showing the currently selected feature in the map (if any). | ||
|
||
The `LayersPanel` component is an example of how another component can interact with the map through the `MapFacade` class. | ||
|
||
```ts | ||
import { | ||
MapStateContainerComponent, | ||
MapFacade, | ||
LayersPanel, | ||
} from '@geonetwork-ui/feature/map' | ||
``` | ||
|
||
```html | ||
<gn-ui-map-state-container></gn-ui-map-state-container> | ||
<gn-ui-layers-panel class="absolute inset-y-0 left-0"></gn-ui-layers-panel> | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './map-context.fixtures' |
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,53 @@ | ||
import { polygonFeatureCollectionFixture } from '../geojson.fixtures' | ||
import { Extent } from 'ol/extent' | ||
import type { | ||
MapContext, | ||
MapContextLayer, | ||
MapContextView, | ||
} from '@geospatial-sdk/core' | ||
|
||
export const mapCtxLayerXyzFixture = (): MapContextLayer => ({ | ||
type: 'xyz', | ||
url: 'https://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png', | ||
attributions: '<a href="https://www.openstreetmap.org/copyright">', | ||
}) | ||
|
||
export const mapCtxLayerWmsFixture = (): MapContextLayer => ({ | ||
type: 'wms', | ||
url: 'https://www.geograndest.fr/geoserver/region-grand-est/ows?REQUEST=GetCapabilities&SERVICE=WMS', | ||
name: 'commune_actuelle_3857', | ||
}) | ||
|
||
export const mapCtxLayerWfsFixture = (): MapContextLayer => ({ | ||
type: 'wfs', | ||
url: 'https://www.geograndest.fr/geoserver/region-grand-est/ows?REQUEST=GetCapabilities&SERVICE=WFS&VERSION=1.1.0', | ||
featureType: 'ms:commune_actuelle_3857', | ||
}) | ||
|
||
export const mapCtxLayerGeojsonFixture = (): MapContextLayer => ({ | ||
type: 'geojson', | ||
data: polygonFeatureCollectionFixture(), | ||
}) | ||
|
||
export const mapCtxLayerGeojsonRemoteFixture = (): MapContextLayer => ({ | ||
type: 'geojson', | ||
url: 'https://my.host.com/data/regions.json', | ||
}) | ||
|
||
export const mapCtxViewFixture = (): MapContextView => ({ | ||
center: [7.75, 48.6], | ||
zoom: 9, | ||
}) | ||
|
||
export const mapCtxFixture = (): MapContext => ({ | ||
layers: [ | ||
mapCtxLayerXyzFixture(), | ||
mapCtxLayerWmsFixture(), | ||
mapCtxLayerGeojsonFixture(), | ||
], | ||
view: mapCtxViewFixture(), | ||
}) | ||
|
||
export const mapCtxExtentFixture = (): Extent => [ | ||
171083.69713494915, 6246047.945419401, 476970.39956295764, 6631079.362882684, | ||
] |
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.