comparison client/src/components/map/layers.js @ 3271:b74e9768231d

client: map layers: added support for vuex store in layer configuration
author Markus Kottlaender <markus@intevation.de>
date Wed, 15 May 2019 14:15:45 +0200
parents d7bc51fd50b0
children 80037790032d
comparison
equal deleted inserted replaced
3270:d7bc51fd50b0 3271:b74e9768231d
12 import { WFS, GeoJSON } from "ol/format"; 12 import { WFS, GeoJSON } from "ol/format";
13 import OSM from "ol/source/OSM"; 13 import OSM from "ol/source/OSM";
14 import { equalTo } from "ol/format/filter"; 14 import { equalTo } from "ol/format/filter";
15 import { HTTP } from "@/lib/http"; 15 import { HTTP } from "@/lib/http";
16 import styles from "./styles"; 16 import styles from "./styles";
17 import store from "@/store/index";
17 18
18 const buildVectorLoader = ( 19 const buildVectorLoader = (
19 featureRequestOptions, 20 featureRequestOptions,
20 vectorSource, 21 vectorSource,
21 bboxStrategyDisabled, 22 bboxStrategyDisabled,
49 .then(response => { 50 .then(response => {
50 const features = new GeoJSON().readFeatures( 51 const features = new GeoJSON().readFeatures(
51 JSON.stringify(response.data) 52 JSON.stringify(response.data)
52 ); 53 );
53 if (featurePostProcessor) { 54 if (featurePostProcessor) {
54 features.map(f => featurePostProcessor(f)); 55 features.map(f => featurePostProcessor(f, store));
55 } 56 }
56 vectorSource.addFeatures(features); 57 vectorSource.addFeatures(features);
57 }) 58 })
58 .catch(() => { 59 .catch(() => {
59 vectorSource.removeLoadedExtent(extent); 60 vectorSource.removeLoadedExtent(extent);
211 { 212 {
212 featureTypes: ["stretches_geoserver"], 213 featureTypes: ["stretches_geoserver"],
213 geometryName: "area" 214 geometryName: "area"
214 }, 215 },
215 source, 216 source,
216 f => { 217 true,
217 if (f.getId() === this.selectedStretchId) { 218 (f, store) => {
219 if (f.getId() === store.state.imports.selectedStretchId) {
218 f.set("highlighted", true); 220 f.set("highlighted", true);
219 } 221 }
220 return f; 222 return f;
221 } 223 }
222 ) 224 )