Mercurial > gemma
changeset 3749:f20bd1aee549
client: search: zoom to bounding box if feature has one
author | Markus Kottlaender <markus@intevation.de> |
---|---|
date | Mon, 24 Jun 2019 17:43:54 +0200 |
parents | 4bb5dfa0b7e3 |
children | 96d6e6417819 ac12e135d4b8 |
files | client/src/components/Search.vue |
diffstat | 1 files changed, 37 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/client/src/components/Search.vue Mon Jun 24 16:28:12 2019 +0200 +++ b/client/src/components/Search.vue Mon Jun 24 17:43:54 2019 +0200 @@ -187,6 +187,7 @@ ]), ...mapState("imports", ["startDate", "endDate"]), ...mapGetters("imports", ["filters"]), + ...mapGetters("map", ["openLayersMap"]), searchQuery: { get() { return this.$store.state.application.searchQuery; @@ -299,17 +300,48 @@ this.searchQueryIsDirty = false; }, moveToSearchResult(resultEntry) { + let zoom = 16; + if (resultEntry.type === "bottleneck") { + this.openLayersMap() + .getLayer("BOTTLENECKS") + .setVisible(true); + } + if (resultEntry.type === "rhm") { + this.openLayersMap() + .getLayer("DISTANCEMARKSAXIS") + .setVisible(true); + } + if (resultEntry.type === "gauge") { + this.openLayersMap() + .getLayer("GAUGES") + .setVisible(true); + } + if (resultEntry.type === "stretch") { + this.openLayersMap() + .getLayer("STRETCHES") + .setVisible(true); + } + if (resultEntry.type === "section") { + this.openLayersMap() + .getLayer("SECTIONS") + .setVisible(true); + } + if (resultEntry.type === "city") zoom = 13; + if (resultEntry.geom.type == "Point") { - let zoom = 11; - if (resultEntry.type === "bottleneck") zoom = 17; - if (resultEntry.type === "rhm") zoom = 15; - if (resultEntry.type === "city") zoom = 13; - if (resultEntry.type === "gauge") zoom = 15; this.$store.dispatch("map/moveMap", { coordinates: resultEntry.geom.coordinates, zoom, preventZoomOut: true }); + } else if (resultEntry.geom.type == "Polygon") { + const boundingBox = [ + Math.min(...resultEntry.geom.coordinates[0].map(c => c[0])), + Math.min(...resultEntry.geom.coordinates[0].map(c => c[1])), + Math.max(...resultEntry.geom.coordinates[0].map(c => c[0])), + Math.max(...resultEntry.geom.coordinates[0].map(c => c[1])) + ]; + this.$store.dispatch("map/moveToBoundingBox", { boundingBox, zoom }); } // this.searchQuery = ""; // clear search query again this.toggleSearchbar();