* For "local" content, getProjection will use content of "this" * For "remote" content, you need to pass the shadowRoot to search through
()
| 451 | * For "remote" content, you need to pass the shadowRoot to search through |
| 452 | */ |
| 453 | getProjection() { |
| 454 | let mapml = this.src ? this.shadowRoot : this; |
| 455 | let projection = this.parentElement.projection; |
| 456 | if (mapml.querySelector('map-meta[name=projection][content]')) { |
| 457 | projection = |
| 458 | Util._metaContentToObject( |
| 459 | mapml |
| 460 | .querySelector('map-meta[name=projection]') |
| 461 | .getAttribute('content') |
| 462 | ).content || projection; |
| 463 | } else if (mapml.querySelector('map-extent[units]')) { |
| 464 | const getProjectionFrom = (extents) => { |
| 465 | let extentProj = extents[0].attributes.units.value; |
| 466 | let isMatch = true; |
| 467 | for (let i = 0; i < extents.length; i++) { |
| 468 | if (extentProj !== extents[i].attributes.units.value) { |
| 469 | isMatch = false; |
| 470 | } |
| 471 | } |
| 472 | return isMatch ? extentProj : null; |
| 473 | }; |
| 474 | projection = |
| 475 | getProjectionFrom( |
| 476 | Array.from(mapml.querySelectorAll('map-extent[units]')) |
| 477 | ) || projection; |
| 478 | } else { |
| 479 | const message = `A projection was not assigned to the '${mapml.label}' Layer. \nPlease specify a projection for that layer using a map-meta element. \nSee more here - https://maps4html.org/web-map-doc/docs/elements/meta/`; |
| 480 | if (!this.loggedMessages.has(message)) { |
| 481 | console.log(message); |
| 482 | this.loggedMessages.add(message); |
| 483 | } |
| 484 | } |
| 485 | return projection; |
| 486 | } |
| 487 | /* |
| 488 | * Runs the effects of the mutation observer for child elements of map-layer. |
| 489 | * This method primarily handles extent recalculation and other |
no test coverage detected