view client/src/components/Map.vue @ 519:6a29ad5a36cf

refac: Map component converted to vue component. Map is now a vue-component with parametrized lat, long, zoom
author Thomas Junk <thomas.junk@intevation.de>
date Mon, 27 Aug 2018 16:39:58 +0200
parents
children e5dab193207a
line wrap: on
line source

<template>
  <div id="map"></div>  
</template>

<style lang="sass">

</style>

<script>
import "ol/ol.css";
import { Map, View } from "ol";
import TileLayer from "ol/layer/Tile";
import OSM from "ol/source/OSM";
import TileWMS from "ol/source/TileWMS.js";

export default {
  name: "map",
  props: ["lat", "long", "zoom"],
  data() {
    return {
      projection: "EPSG:3857"
    };
  },
  mounted() {
    new Map({
      layers: [
        new TileLayer({
          source: new OSM()
        }),
        new TileLayer({
          source: new TileWMS({
            url: "https://demo.d4d-portal.info/wms",
            params: { LAYERS: "d4d", VERSION: "1.1.1", TILED: true }
          })
        })
      ],
      target: "map",
      view: new View({
        center: [this.long, this.lat],
        zoom: this.zoom,
        projection: this.projection
      })
    });
  }
};
</script>