Mercurial > gemma
comparison client/src/components/map/layers.js @ 4942:c4d84be3a476 fairway-marks-import
add fairwaymarks layer
author | Thomas Junk <thomas.junk@intevation.de> |
---|---|
date | Tue, 18 Feb 2020 09:10:05 +0100 |
parents | 5555b77b8c4e |
children | 6256d1bca8f6 |
comparison
equal
deleted
inserted
replaced
4938:9f9d72a1d398 | 4942:c4d84be3a476 |
---|---|
1 import { GeoJSON, WFS } from "ol/format"; | |
2 import { Icon, Stroke, Style } from "ol/style"; | |
3 import { | |
4 Image as ImageLayer, | |
5 Tile as TileLayer, | |
6 Vector as VectorLayer | |
7 } from "ol/layer"; | |
8 import { and as andFilter, equalTo } from "ol/format/filter"; | |
9 | |
10 import { HTTP } from "@/lib/http"; | |
11 import { ImageWMS as ImageSource } from "ol/source"; | |
12 import OSM from "ol/source/OSM"; | |
13 import Point from "ol/geom/Point"; | |
1 import TileWMS from "ol/source/TileWMS"; | 14 import TileWMS from "ol/source/TileWMS"; |
2 import { | |
3 Tile as TileLayer, | |
4 Vector as VectorLayer, | |
5 Image as ImageLayer | |
6 } from "ol/layer"; | |
7 import { Icon, Stroke, Style } from "ol/style"; | |
8 import VectorSource from "ol/source/Vector"; | 15 import VectorSource from "ol/source/Vector"; |
9 import { ImageWMS as ImageSource } from "ol/source"; | |
10 import Point from "ol/geom/Point"; | |
11 import { bbox as bboxStrategy } from "ol/loadingstrategy"; | 16 import { bbox as bboxStrategy } from "ol/loadingstrategy"; |
12 import { WFS, GeoJSON } from "ol/format"; | 17 import store from "@/store/index"; |
13 import OSM from "ol/source/OSM"; | |
14 import { equalTo, and as andFilter } from "ol/format/filter"; | |
15 import { HTTP } from "@/lib/http"; | |
16 import { styleFactory } from "./styles"; | 18 import { styleFactory } from "./styles"; |
17 import store from "@/store/index"; | |
18 | 19 |
19 export const buildVectorLoader = ( | 20 export const buildVectorLoader = ( |
20 featureRequestOptions, | 21 featureRequestOptions, |
21 vectorSource, | 22 vectorSource, |
22 bboxStrategyDisabled, | 23 bboxStrategyDisabled, |
258 label: "Waterway Area", | 259 label: "Waterway Area", |
259 maxResolution: 100, | 260 maxResolution: 100, |
260 minResolution: 0, | 261 minResolution: 0, |
261 source: new ImageSource({ | 262 source: new ImageSource({ |
262 url: window.location.origin + "/api/internal/wms", | 263 url: window.location.origin + "/api/internal/wms", |
263 params: { LAYERS: "waterway_area", VERSION: "1.1.1", TILED: true }, | 264 params: { |
265 LAYERS: "waterway_area", | |
266 VERSION: "1.1.1", | |
267 TILED: true | |
268 }, | |
264 imageLoadFunction: function(tile, src) { | 269 imageLoadFunction: function(tile, src) { |
265 HTTP.get(src, { | 270 HTTP.get(src, { |
266 headers: { | 271 headers: { |
267 "X-Gemma-Auth": localStorage.getItem("token") | 272 "X-Gemma-Auth": localStorage.getItem("token") |
268 }, | 273 }, |
474 new ImageLayer({ | 479 new ImageLayer({ |
475 id: "WATERWAYAXIS", | 480 id: "WATERWAYAXIS", |
476 label: "Waterway Axis", | 481 label: "Waterway Axis", |
477 source: new ImageSource({ | 482 source: new ImageSource({ |
478 url: window.location.origin + "/api/internal/wms", | 483 url: window.location.origin + "/api/internal/wms", |
479 params: { LAYERS: "waterway_axis", VERSION: "1.1.1", TILED: true }, | 484 params: { |
485 LAYERS: "waterway_axis", | |
486 VERSION: "1.1.1", | |
487 TILED: true | |
488 }, | |
480 imageLoadFunction: function(tile, src) { | 489 imageLoadFunction: function(tile, src) { |
481 HTTP.get(src, { | 490 HTTP.get(src, { |
482 headers: { | 491 headers: { |
483 "X-Gemma-Auth": localStorage.getItem("token") | 492 "X-Gemma-Auth": localStorage.getItem("token") |
484 }, | 493 }, |
666 maxResolution: 100, | 675 maxResolution: 100, |
667 minResolution: 0, | 676 minResolution: 0, |
668 source | 677 source |
669 }); | 678 }); |
670 })(), | 679 })(), |
680 new TileLayer({ | |
681 id: "FAIRWAYMARKS", | |
682 label: "Fairway marks", | |
683 visible: false, | |
684 source: new TileWMS({ | |
685 preload: 0, | |
686 projection: "EPSG:3857", | |
687 url: window.location.origin + "/api/internal/wms", | |
688 params: { | |
689 LAYERS: "fairway_marks", | |
690 VERSION: "1.1.1", | |
691 TILED: true | |
692 }, | |
693 tileLoadFunction: function(tile, src) { | |
694 HTTP.get(src, { | |
695 headers: { | |
696 "X-Gemma-Auth": localStorage.getItem("token") | |
697 }, | |
698 responseType: "blob" | |
699 }) | |
700 .then(response => { | |
701 tile.getImage().src = URL.createObjectURL(response.data); | |
702 }) | |
703 .catch(() => { | |
704 store.dispatch("application/reportBackendError"); | |
705 }); | |
706 } // TODO tile.setState(TileState.ERROR); | |
707 }) | |
708 }), | |
671 DRAWLAYER, | 709 DRAWLAYER, |
672 CUTLAYER, | 710 CUTLAYER, |
673 FDREVIEWLAYER | 711 FDREVIEWLAYER |
674 ]; | 712 ]; |
675 | 713 |