UNPKG

@geogirafe/lib-geoportal

Version:

GeoGirafe is a flexible application to build online geoportals.

34 lines (33 loc) 1.17 kB
import GirafeSingleton from '../../base/GirafeSingleton'; import MapOL from 'ol/Map'; import { defaults as defaultControls } from 'ol/control/defaults.js'; import StateManager from './statemanager'; /** The singleton containing the main OpenLayers map accessible from everywhere */ export default class MapManager extends GirafeSingleton { constructor() { super(...arguments); Object.defineProperty(this, "map", { enumerable: true, configurable: true, writable: true, value: new MapOL({ controls: defaultControls({ rotate: false, zoom: StateManager.getInstance().state.interface.isMobile }), layers: [] }) }); } getMap() { return this.map; } /** * @returns an array of BaseLayer objects that should be printed and that are not in the layer tree. */ getLayersToPrint() { return this.map.getAllLayers().filter((layer) => layer.get('addToPrintedLayers')); } zoomToExtent(extent, minResolution) { this.map.getView().fit(extent, { minResolution: minResolution }); } }