hmpps-open-layers-map
Version:
A native Web Component for displaying maps using OpenLayers.
22 lines (21 loc) • 622 B
JavaScript
import { fromLonLat, toLonLat } from 'ol/proj';
// Adapter for an OpenLayers-backed map instance.
export function createOpenLayersAdapter(hostElement, map) {
return {
mapLibrary: 'openlayers',
hostElement,
project: lonLat => fromLonLat(lonLat),
unproject: xy => toLonLat(xy),
openlayers: { map },
};
}
// Adapter for an MapLibre-backed map instance.
export function createMapLibreAdapter(hostElement, map) {
return {
mapLibrary: 'maplibre',
hostElement,
project: lonLat => lonLat,
unproject: xy => xy,
mapLibre: { map },
};
}