|
64 | 64 | bg-variant="light"
|
65 | 65 | class="float-right"
|
66 | 66 | >
|
| 67 | + <template v-if="spatialExtent"> |
| 68 | + <div id="locator-map"></div> |
| 69 | + </template> |
67 | 70 | <div class="table-responsive">
|
68 | 71 | <table class="table">
|
69 | 72 | <tbody>
|
|
133 | 136 |
|
134 | 137 | <script>
|
135 | 138 | import { HtmlRenderer, Parser } from "commonmark";
|
| 139 | +import Leaflet from "leaflet"; |
136 | 140 | import spdxToHTML from "spdx-to-html";
|
137 | 141 | import { mapActions, mapGetters } from "vuex";
|
138 | 142 |
|
@@ -185,7 +189,8 @@ export default {
|
185 | 189 | }
|
186 | 190 | },
|
187 | 191 | currentPage: 1,
|
188 |
| - perPage: 25 |
| 192 | + perPage: 25, |
| 193 | + locatorMap: null |
189 | 194 | };
|
190 | 195 | },
|
191 | 196 | computed: {
|
@@ -327,8 +332,65 @@ export default {
|
327 | 332 | return this.catalog.version;
|
328 | 333 | }
|
329 | 334 | },
|
| 335 | + mounted() { |
| 336 | + this.initialize(); |
| 337 | + }, |
330 | 338 | methods: {
|
331 | 339 | ...mapActions(["load"]),
|
| 340 | + initialize() { |
| 341 | + if (this.spatialExtent != null) { |
| 342 | + this.initializeLocatorMap(); |
| 343 | + } |
| 344 | + }, |
| 345 | + initializeLocatorMap() { |
| 346 | + this.locatorMap = Leaflet.map("locator-map", { |
| 347 | + attributionControl: false, |
| 348 | + zoomControl: false, |
| 349 | + boxZoom: false, |
| 350 | + doubleClickZoom: false, |
| 351 | + dragging: false, |
| 352 | + scrollWheelZoom: false, |
| 353 | + touchZoom: false |
| 354 | + }); |
| 355 | +
|
| 356 | + Leaflet.tileLayer( |
| 357 | + "https://{s}.basemaps.cartocdn.com/dark_nolabels/{z}/{x}/{y}@2x.png", |
| 358 | + { |
| 359 | + attribution: `Map data <a href="https://www.openstreetmap.org/copyright">© OpenStreetMap contributors</a>, © <a href="https://carto.com/attributions">CARTO</a>` |
| 360 | + } |
| 361 | + ).addTo(this.locatorMap); |
| 362 | + Leaflet.tileLayer( |
| 363 | + "https://{s}.basemaps.cartocdn.com/dark_only_labels/{z}/{x}/{y}@2x.png", |
| 364 | + { |
| 365 | + zIndex: 1000 |
| 366 | + } |
| 367 | + ).addTo(this.locatorMap); |
| 368 | +
|
| 369 | + const [minX, minY, maxX, maxY] = this.spatialExtent; |
| 370 | + const coordinates = [ |
| 371 | + [[minX, minY], [minX, maxY], [maxX, maxY], [maxX, minY], [minX, minY]] |
| 372 | + ]; |
| 373 | +
|
| 374 | + const overlayLayer = Leaflet.geoJSON( |
| 375 | + { |
| 376 | + type: "Polygon", |
| 377 | + coordinates |
| 378 | + }, |
| 379 | + { |
| 380 | + pane: "tilePane", |
| 381 | + style: { |
| 382 | + weight: 3, |
| 383 | + color: "#ffd65d", |
| 384 | + opacity: 1, |
| 385 | + fillOpacity: 0.15 |
| 386 | + } |
| 387 | + } |
| 388 | + ).addTo(this.locatorMap); |
| 389 | +
|
| 390 | + this.locatorMap.fitBounds(overlayLayer.getBounds(), { |
| 391 | + padding: [95, 95] |
| 392 | + }); |
| 393 | + }, |
332 | 394 | sortCompare(a, b, key) {
|
333 | 395 | if (key === "link") {
|
334 | 396 | key = "title";
|
@@ -372,4 +434,14 @@ ul.links li,
|
372 | 434 | ul.items li {
|
373 | 435 | margin: 0 0 0.2em;
|
374 | 436 | }
|
| 437 | +
|
| 438 | +.leaflet-container { |
| 439 | + background-color: #262626; |
| 440 | +} |
| 441 | +
|
| 442 | +#locator-map { |
| 443 | + height: 200px; |
| 444 | + width: 100%; |
| 445 | + margin-bottom: 10px; |
| 446 | +} |
375 | 447 | </style>
|
0 commit comments