Advertisement
Guest User

map.js

a guest
Mar 13th, 2023
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 1.14 KB | Software | 0 0
  1. import Map from 'ol/Map.js';
  2. import View from 'ol/View.js';
  3. import TileLayer from 'ol/layer/Tile.js';
  4. import VectorSource from 'ol/source/Vector';
  5. import VectorLayer from 'ol/layer/Vector';
  6. import OSM from 'ol/source/OSM.js';
  7.  
  8.  
  9. document.addEventListener('alpine:init', () => {
  10.     Alpine.data('map', function () {
  11.         return {
  12.             map: {},
  13.             init() {
  14.                 this.map = new Map({
  15.                     target: this.$refs.map,
  16.                     layers: [
  17.                         new TileLayer({
  18.                             source: new OSM(),
  19.                         }),
  20.                         new VectorLayer({
  21.                             source: new VectorSource({
  22.                                 features: this.features,
  23.                             }),
  24.                             style: this.styleFunction,
  25.                         })
  26.                     ],
  27.                     view: new View({
  28.                         projection: 'EPSG:4326',
  29.                         center: [0, 0],
  30.                         zoom: 2,
  31.                     }),
  32.                 })
  33.             },
  34.         };
  35.     });
  36. });
  37.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement