(e)
| 567 | } |
| 568 | |
| 569 | function attachZoomLink(e) { |
| 570 | // this === popup |
| 571 | let popupWrapper = this._wrapper, |
| 572 | featureEl = e ? e.currFeature : this._source._groupLayer._featureEl; |
| 573 | if (popupWrapper.querySelector('a.mapml-zoom-link')) { |
| 574 | popupWrapper.querySelector('a.mapml-zoom-link').remove(); |
| 575 | } |
| 576 | |
| 577 | // return early if feature doesn't have map-geometry |
| 578 | if (!featureEl.querySelector('map-geometry')) return; |
| 579 | |
| 580 | // calculate zoom parameters |
| 581 | let tL = featureEl.extent.topLeft.gcrs, |
| 582 | bR = featureEl.extent.bottomRight.gcrs, |
| 583 | center = latLngBounds( |
| 584 | latLng(tL.horizontal, tL.vertical), |
| 585 | latLng(bR.horizontal, bR.vertical) |
| 586 | ).getCenter(true); |
| 587 | |
| 588 | // construct zoom link |
| 589 | let zoomLink = document.createElement('a'); |
| 590 | zoomLink.href = `#${featureEl.getZoomToZoom()},${center.lng},${ |
| 591 | center.lat |
| 592 | }`; |
| 593 | zoomLink.innerHTML = `${map.options.mapEl.locale.popupZoom}`; |
| 594 | zoomLink.className = 'mapml-zoom-link'; |
| 595 | |
| 596 | // handle zoom link interactions |
| 597 | zoomLink.onclick = zoomLink.onkeydown = function (e) { |
| 598 | if (!(e instanceof MouseEvent) && e.keyCode !== 13) return; |
| 599 | e.preventDefault(); |
| 600 | featureEl.zoomTo(); |
| 601 | map.closePopup(); |
| 602 | map.getContainer().focus(); |
| 603 | }; |
| 604 | |
| 605 | // we found that the popupopen event is fired as many times as there |
| 606 | // are layers on the map (<map-layer> elements / MapLayers that is). |
| 607 | // In each case the target layer is always this layer, so we can't |
| 608 | // detect and conditionally add the zoomLink if the target is not this. |
| 609 | // so, like Ahmad, we are taking a 'delete everyting each time' |
| 610 | // approach (see _attachSkipButtons for this approach taken with |
| 611 | // feature navigation buttons); obviously he dealt with this leaflet bug |
| 612 | // this way some time ago, and we can't figure out how to get around it |
| 613 | // apart from this slightly non-optimal method. Revisit sometime! |
| 614 | let link = popupWrapper.querySelector('.mapml-zoom-link'); |
| 615 | if (link) link.remove(); |
| 616 | |
| 617 | // attach link to popup |
| 618 | popupWrapper.insertBefore( |
| 619 | zoomLink, |
| 620 | popupWrapper.querySelector('hr.mapml-popup-divider') |
| 621 | ); |
| 622 | } |
| 623 | |
| 624 | // if popup closes then the focusFeature handler can be removed |
| 625 | map.on('popupclose', removeHandlers); |
nothing calls this directly
no test coverage detected