-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DBC22-1935: added advisory layer on map
- Loading branch information
Showing
5 changed files
with
100 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
.advisories-on-map { | ||
position: relative; | ||
top: 1rem; | ||
top: 6rem; | ||
left: 1rem; | ||
width: fit-content; | ||
|
||
|
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 @@ | ||
// Components and functions | ||
import { transformFeature } from '../helper.js'; | ||
|
||
// OpenLayers | ||
import { Polygon } from 'ol/geom'; | ||
import * as ol from 'ol'; | ||
import GeoJSON from 'ol/format/GeoJSON.js'; | ||
import VectorLayer from 'ol/layer/Vector'; | ||
import VectorSource from 'ol/source/Vector'; | ||
|
||
// Styling | ||
import { advisoryStyles } from '../../data/featureStyleDefinitions.js'; | ||
|
||
export function getAdvisoriesLayer( | ||
advisories, | ||
projectionCode, | ||
mapContext, | ||
) { | ||
return new VectorLayer({ | ||
classname: 'advisories', | ||
visible: true, | ||
source: new VectorSource({ | ||
format: new GeoJSON(), | ||
loader: function (extent, resolution, projection) { | ||
const vectorSource = this; | ||
vectorSource.clear(); | ||
|
||
advisories.forEach(advisory => { | ||
// Build a new OpenLayers feature | ||
const olGeometry = new Polygon(advisory.geometry.coordinates); | ||
const olFeature = new ol.Feature({ geometry: olGeometry }); | ||
|
||
// Transform the projection | ||
const olFeatureForMap = transformFeature( | ||
olFeature, | ||
'EPSG:4326', | ||
projectionCode, | ||
); | ||
|
||
// feature ID to advisory ID for retrieval | ||
olFeatureForMap.setId(advisory.id); | ||
|
||
vectorSource.addFeature(olFeatureForMap); | ||
}); | ||
}, | ||
}), | ||
|
||
style: () => advisoryStyles.polygon, | ||
}); | ||
} |
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