]> git.argeo.org Git - gpl/argeo-suite.git/blobdiff - js/src/geo/OpenLayersMapPart.js
Improve GIS for release
[gpl/argeo-suite.git] / js / src / geo / OpenLayersMapPart.js
index a75956680ee1e165ebf0151015d973725df8ef62..0e32e8832c410226de3e2c56fd9e6df105f671d1 100644 (file)
@@ -4,8 +4,6 @@
 
 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';
@@ -16,6 +14,7 @@ import GPX from 'ol/format/GPX.js';
 import Select from 'ol/interaction/Select.js';
 import Overlay from 'ol/Overlay.js';
 import { Style, Icon } from 'ol/style.js';
+import { transformExtent } from 'ol/proj.js';
 
 import * as SLDReader from '@nieuwlandgeo/sldreader';
 
@@ -37,21 +36,15 @@ export default class OpenLayersMapPart extends MapPart {
                super(mapName);
                this.#map = new Map({
                        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 */
@@ -60,8 +53,13 @@ export default class OpenLayersMapPart extends MapPart {
                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) {
@@ -282,4 +280,4 @@ export default class OpenLayersMapPart extends MapPart {
                });
                vectorLayer.setStyle(olStyleFunction);
        }
-}
\ No newline at end of file
+}