view client/src/map/store.js @ 620:ef00684e021f

client: add showing special buoys * Add hardwired a point layer with an external wfs configured like in the standard readme showing the special/general buoys.
author Bernhard Reiter <bernhard@intevation.de>
date Tue, 11 Sep 2018 12:38:34 +0200
parents b7b69d25cafe
children 4acf60d1bbb4
line wrap: on
line source

//import { HTTP } from "../lib/http";

import TileWMS from "ol/source/TileWMS.js";
import { Tile as TileLayer, Vector as VectorLayer } from "ol/layer.js";
import OSM from "ol/source/OSM";
import { Stroke, Style } from "ol/style.js";
import VectorSource from "ol/source/Vector.js";

const MapStore = {
  namespaced: true,
  state: {
    layers: [
      {
        name: "Open Streetmap",
        data: new TileLayer({
          source: new OSM()
        }),
        isVisible: true
      },
      {
        name: "Inland ECDIS chart Danube (D4D)",
        data: new TileLayer({
          source: new TileWMS({
            url: "https://demo.d4d-portal.info/wms",
            params: { LAYERS: "d4d", VERSION: "1.1.1", TILED: true }
          })
        }),
        isVisible: true
      },
      {
        name: "Fairways Dimensions",
        data: new VectorLayer({
          source: new VectorSource(),
          style: new Style({
            stroke: new Stroke({
              color: "rgba(0, 0, 255, 1.0)",
              width: 2
            })
          })
        }),
        isVisible: true
      },
      {
        name: "Buoy, special purpose/general",
        data: new VectorLayer({
          source: new VectorSource() /*,
            style: new Style({
            stroke: new Stroke({
              color: "rgba(0, 0, 255, 1.0)",
              width: 2
            })
          })
          */
        }),
        isVisible: true
      }
    ]
  },
  getters: {
    layers: state => {
      return state.layers;
    }
  },
  mutations: {
    toggleVisibility: (state, layer) => {
      state.layers[layer].isVisible = !state.layers[layer].isVisible;
      state.layers[layer].data.setVisible(state.layers[layer].isVisible);
    }
  }
};

export default MapStore;