* @module OpenLayersMapPart
*/
-import Map from 'ol/Map.js';
-import View from 'ol/View.js';
-import OSM from 'ol/source/OSM.js';
-import TileLayer from 'ol/layer/Tile.js';
import { fromLonLat, getPointResolution } from 'ol/proj.js';
-import VectorSource from 'ol/source/Vector.js';
import Feature from 'ol/Feature.js';
import { Point } from 'ol/geom.js';
+import { transformExtent } from 'ol/proj.js';
+
import VectorLayer from 'ol/layer/Vector.js';
+import TileLayer from 'ol/layer/Tile.js';
+
+import VectorSource from 'ol/source/Vector.js';
import GeoJSON from 'ol/format/GeoJSON.js';
import GPX from 'ol/format/GPX.js';
+import OSM from 'ol/source/OSM.js';
+
import Select from 'ol/interaction/Select.js';
import Overlay from 'ol/Overlay.js';
import { Style, Icon } from 'ol/style.js';
+import Map from 'ol/Map.js';
+import View from 'ol/View.js';
+import { OverviewMap, ScaleLine, defaults as defaultControls } from 'ol/control.js';
+
import * as SLDReader from '@nieuwlandgeo/sldreader';
import MapPart from './MapPart.js';
/** The OpenLayers Map. */
#map;
+ #overviewMap;
+
/** Styled layer descriptor */
#sld;
/** Constructor taking the mapName as an argument. */
constructor(mapName) {
super(mapName);
+ this.#overviewMap = new OverviewMap({
+ layers: [
+ new TileLayer({
+ source: new OSM(),
+ }),
+ ],
+ });
this.#map = new Map({
+ controls: defaultControls({
+ attribution: false,
+ rotate: false,
+ }).extend([this.#overviewMap, new ScaleLine({
+ bar: false,
+ steps: 2,
+ text: false,
+ minWidth: 150,
+ maxWidth: 200,
+ })]),
layers: [
- // new TileLayer({
- // source: new SentinelCloudless(),
- // }),
- // new TileLayer({
- // source: new OSM(),
- // opacity: 0.4,
- // transition: 0,
- // }),
],
- // view: new View({
- // center: [0, 0],
- // zoom: 2,
- // }),
+ // view: new View({
+ // projection: 'EPSG:4326',
+ // center: [0, 0],
+ // zoom: 2,
+ // }),
target: this.getMapName(),
});
+ //this.#map.getView().set('projection', 'EPSG:4326', true);
}
/* GEOGRAPHICAL METHODS */
this.#map.getView().setZoom(zoom);
}
- setCenter(lng, lat) {
- this.#map.getView().setCenter(fromLonLat([lng, lat]));
+ setCenter(lat, lon) {
+ this.#map.getView().setCenter(fromLonLat([lon, lat]));
+ }
+
+ fit(extent, options) {
+ var transformed = transformExtent(extent, 'EPSG:4326', this.#map.getView().getProjection());
+ this.#map.getView().fit(transformed, options);
}
addPoint(lng, lat, style) {
});
vectorLayer.setStyle(olStyleFunction);
}
-}
\ No newline at end of file
+}