X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=js%2Fsrc%2Fgeo%2FOpenLayersMapPart.js;h=a1fc2b852f1e9a298f9bf07a2615664f31cc3f6d;hb=9cfc7842603c9c09d686ab9972099ed0a7c22a6e;hp=71b9a17b0574dd1539e1eb00c4cc5fa7823598c6;hpb=b384a9cbe93b83b3aa94fe46cf2ff0a929f0332c;p=gpl%2Fargeo-suite.git diff --git a/js/src/geo/OpenLayersMapPart.js b/js/src/geo/OpenLayersMapPart.js index 71b9a17..a1fc2b8 100644 --- a/js/src/geo/OpenLayersMapPart.js +++ b/js/src/geo/OpenLayersMapPart.js @@ -4,9 +4,7 @@ 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, transformExtent } from 'ol/proj.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'; @@ -21,8 +19,6 @@ import * as SLDReader from '@nieuwlandgeo/sldreader'; import MapPart from './MapPart.js'; -import { bbox } from 'ol/loadingstrategy'; - /** OpenLayers implementation of MapPart. */ export default class OpenLayersMapPart extends MapPart { /** The OpenLayers Map. */ @@ -39,14 +35,6 @@ 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({ // projection: 'EPSG:4326', @@ -287,43 +275,4 @@ export default class OpenLayersMapPart extends MapPart { vectorLayer.setStyle(olStyleFunction); } - // - // BBOX - // - applyBboxStrategy(layerName) { - const layer = this.getLayerByName(layerName); - const vectorSource = layer.getSource(); - const baseUrl = vectorSource.getUrl(); - if (typeof baseUrl === 'function') - throw new Error('A strategy was already applied to layer ' + layerName); - - const loadFunction = function(extent, resolution, projection, success, failure) { - - const proj = projection.getCode(); - var bbox = transformExtent(extent, proj, 'EPSG:4326'); - - const url = baseUrl + '&' + - 'bbox=' + bbox.join(',') ; -// 'bbox=' + extent.join(',') + ',' + proj; - const xhr = new XMLHttpRequest(); - xhr.open('GET', url); - const onError = function() { - vectorSource.removeLoadedExtent(extent); - failure(); - } - xhr.onerror = onError; - xhr.onload = function() { - if (xhr.status == 200) { - const features = vectorSource.getFormat().readFeatures(xhr.responseText); - vectorSource.addFeatures(features); - success(features); - } else { - onError(); - } - } - xhr.send(); - } - - vectorSource.setLoader(loadFunction); - } }