|
1 | 1 | import Vue from 'vue'; |
2 | 2 | import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'; |
| 3 | + |
| 4 | +import * as Leaflet from 'leaflet'; |
| 5 | +import 'esri-leaflet'; |
| 6 | +import * as EsriLeafletVector from 'esri-leaflet-vector'; |
| 7 | +import '../../css/leaflet-custom.css'; |
| 8 | +import Routing from '../../../vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.min'; |
3 | 9 | import FileManager from '../vue/FileManager.vue'; |
4 | 10 | import '../../css/file-manager.css'; |
5 | 11 | import '@fortawesome/fontawesome-free/css/all.min.css'; |
6 | 12 | import DownloadZipBtn from '../vue/components/data-land/DownloadZipBtn.vue'; |
7 | 13 | import HelpModal from '../vue/components/data-land/HelpModal.vue'; |
8 | 14 | import '../../scss/data-land.scss'; |
9 | 15 |
|
| 16 | +const leafletMap = document.getElementById('leaflet-map'); |
| 17 | + |
| 18 | +if (typeof (leafletMap) !== 'undefined' && leafletMap != null) { |
| 19 | + const { datasetId } = leafletMap.dataset; |
| 20 | + const esriApiKey = process.env.ESRI_API_KEY; |
| 21 | + |
| 22 | + const GRIIDCStyle = { |
| 23 | + color: 'orange', |
| 24 | + weight: 4, |
| 25 | + opacity: 1, |
| 26 | + fillOpacity: 0.15, |
| 27 | + }; |
| 28 | + |
| 29 | + const map = Leaflet.map('leaflet-map', { |
| 30 | + preferCanvas: true, |
| 31 | + minZoom: 3, |
| 32 | + maxZoom: 14, |
| 33 | + attributionControl: true, |
| 34 | + worldCopyJump: true, |
| 35 | + }); |
| 36 | + |
| 37 | + const basemapEnum = 'ArcGIS:Imagery'; |
| 38 | + EsriLeafletVector.vectorBasemapLayer(basemapEnum, { |
| 39 | + apiKey: esriApiKey, |
| 40 | + }).addTo(map); |
| 41 | + |
| 42 | + Leaflet.featureGroup().addTo(map); |
| 43 | + |
| 44 | + const url = `${Routing.generate('pelagos_app_ui_dataland_get_json')}/${datasetId}`; |
| 45 | + fetch(url).then((response) => response.json()).then((response) => { |
| 46 | + const geojsonMarkerOptions = { |
| 47 | + radius: 12, |
| 48 | + fill: false, |
| 49 | + weight: 4, |
| 50 | + opacity: 1, |
| 51 | + }; |
| 52 | + const geojsonLayer = Leaflet.geoJson(response, { |
| 53 | + pointToLayer(feature, latlng) { |
| 54 | + return Leaflet.circleMarker(latlng, geojsonMarkerOptions); |
| 55 | + }, |
| 56 | + style: GRIIDCStyle, |
| 57 | + onEachFeature(feature, layer) { |
| 58 | + layer.bindTooltip(feature.properties.name.toString(), { permanent: false, className: 'label' }); |
| 59 | + }, |
| 60 | + }).addTo(map); |
| 61 | + const bounds = geojsonLayer.getBounds(); |
| 62 | + map.fitBounds(bounds, { padding: [20, 20] }); |
| 63 | + }); |
| 64 | +} |
| 65 | + |
10 | 66 | // Mount File Manager vue component |
11 | 67 | const fileManagerElement = document.getElementById('file-manager-app'); |
12 | 68 | if (fileManagerElement) { |
@@ -87,25 +143,6 @@ if (helpBtnElement) { |
87 | 143 | }); |
88 | 144 | } |
89 | 145 |
|
90 | | -// eslint-disable-next-line no-undef |
91 | | -const dlmap = new GeoViz(); |
92 | | - |
93 | | -dlmap.initMap('dlolmap', { |
94 | | - onlyOneFeature: false, allowModify: false, allowDelete: false, staticMap: false, labelAttr: 'udi', |
95 | | -}); |
96 | | - |
97 | | -// eslint-disable-next-line no-undef |
98 | | -const geovizMap = $('#dlolmap'); |
99 | | - |
100 | | -if (geovizMap.attr('description') !== '' && geovizMap.attr('wkt') === '') { |
101 | | - const imagePath = geovizMap.attr('labimage'); |
102 | | - dlmap.addImage(imagePath, 0.4); |
103 | | - dlmap.makeStatic(); |
104 | | -} else if (geovizMap.attr('wkt')) { |
105 | | - dlmap.addFeatureFromWKT(geovizMap.attr('wkt'), { udi: geovizMap.attr('udi') }); |
106 | | - dlmap.gotoAllFeatures(); |
107 | | -} |
108 | | - |
109 | 146 | const metadataDownloadBtn = document.getElementById('metadata-download'); |
110 | 147 | if (metadataDownloadBtn) { |
111 | 148 | metadataDownloadBtn.addEventListener('click', () => { |
|
0 commit comments