comparison client/src/map/Maplayer.vue @ 1160:c8c26912754c

disable identifying when draw/cut mode are active
author Markus Kottlaender <markus@intevation.de>
date Tue, 13 Nov 2018 14:50:12 +0100
parents f498494fceb5
children 03c820e25573
comparison
equal deleted inserted replaced
1159:f498494fceb5 1160:c8c26912754c
57 projection: "EPSG:3857" 57 projection: "EPSG:3857"
58 }; 58 };
59 }, 59 },
60 computed: { 60 computed: {
61 ...mapGetters("map", ["getLayerByName"]), 61 ...mapGetters("map", ["getLayerByName"]),
62 ...mapState("map", ["layers", "openLayersMap"]), 62 ...mapState("map", ["layers", "openLayersMap", "drawMode", "cutMode"]),
63 ...mapState("bottlenecks", ["selectedSurvey"]), 63 ...mapState("bottlenecks", ["selectedSurvey"]),
64 mapStyle() { 64 mapStyle() {
65 return { 65 return {
66 mapfull: !this.split, 66 mapfull: !this.split,
67 mapsplit: this.split 67 mapsplit: this.split
68 }; 68 };
69 } 69 }
70 }, 70 },
71 methods: { 71 methods: {
72 identify(coordinate, pixel) { 72 identify(coordinate, pixel) {
73 this.$store.commit("map/setIdentifiedFeatures", []); 73 if (!this.drawMode && !this.cutMode) {
74 // checking our WFS layers 74 this.$store.commit("map/setIdentifiedFeatures", []);
75 var features = this.openLayersMap.getFeaturesAtPixel(pixel); 75 // checking our WFS layers
76 if (features) { 76 var features = this.openLayersMap.getFeaturesAtPixel(pixel);
77 this.$store.commit("map/setIdentifiedFeatures", features); 77 if (features) {
78 78 this.$store.commit("map/setIdentifiedFeatures", features);
79 // get selected bottleneck from identified features 79
80 for (let feature of features) { 80 // get selected bottleneck from identified features
81 let id = feature.getId(); 81 for (let feature of features) {
82 // RegExp.prototype.test() works with number, str and undefined 82 let id = feature.getId();
83 if (/^bottlenecks\./.test(id)) { 83 // RegExp.prototype.test() works with number, str and undefined
84 this.$store.dispatch( 84 if (/^bottlenecks\./.test(id)) {
85 "bottlenecks/setSelectedBottleneck", 85 this.$store.dispatch(
86 feature.get("objnam") 86 "bottlenecks/setSelectedBottleneck",
87 ); 87 feature.get("objnam")
88 this.$store.commit("map/moveMap", { 88 );
89 coordinates: getCenter( 89 this.$store.commit("map/moveMap", {
90 feature 90 coordinates: getCenter(
91 .getGeometry() 91 feature
92 .clone() 92 .getGeometry()
93 .transform("EPSG:3857", "EPSG:4326") 93 .clone()
94 .getExtent() 94 .transform("EPSG:3857", "EPSG:4326")
95 ), 95 .getExtent()
96 zoom: 17, 96 ),
97 preventZoomOut: true 97 zoom: 17,
98 }); 98 preventZoomOut: true
99 });
100 }
99 } 101 }
100 } 102 }
101 } 103
102 104 // DEBUG output and example how to remove the GeometryName
103 // DEBUG output and example how to remove the GeometryName 105 /*
104 /* 106 for (let feature of features) {
105 for (let feature of features) { 107 console.log("Identified:", feature.getId());
106 console.log("Identified:", feature.getId()); 108 for (let key of feature.getKeys()) {
107 for (let key of feature.getKeys()) { 109 if (key != feature.getGeometryName()) {
108 if (key != feature.getGeometryName()) { 110 console.log(key, feature.get(key));
109 console.log(key, feature.get(key)); 111 }
110 } 112 }
111 } 113 }
112 } 114 */
113 */ 115
114 116 // trying the GetFeatureInfo way for WMS
115 // trying the GetFeatureInfo way for WMS 117 var wmsSource = this.getLayerByName(
116 var wmsSource = this.getLayerByName( 118 "Inland ECDIS chart Danube"
117 "Inland ECDIS chart Danube" 119 ).data.getSource();
118 ).data.getSource(); 120 var url = wmsSource.getGetFeatureInfoUrl(
119 var url = wmsSource.getGetFeatureInfoUrl( 121 coordinate,
120 coordinate, 122 100 /* resolution */,
121 100 /* resolution */, 123 "EPSG:3857",
122 "EPSG:3857", 124 // { INFO_FORMAT: "application/vnd.ogc.gml" } // not allowed by d4d
123 // { INFO_FORMAT: "application/vnd.ogc.gml" } // not allowed by d4d 125 { INFO_FORMAT: "text/plain" }
124 { INFO_FORMAT: "text/plain" } 126 );
125 ); 127
126 128 if (url) {
127 if (url) { 129 // cannot directly query here because of SOP
128 // cannot directly query here because of SOP 130 console.log("GetFeatureInfo url:", url);
129 console.log("GetFeatureInfo url:", url); 131 }
130 } 132 }
131 }, 133 },
132 buildVectorLoader(featureRequestOptions, endpoint, vectorSource) { 134 buildVectorLoader(featureRequestOptions, endpoint, vectorSource) {
133 // build a function to be used for VectorSource.setLoader() 135 // build a function to be used for VectorSource.setLoader()
134 // make use of WFS().writeGetFeature to build the request 136 // make use of WFS().writeGetFeature to build the request