()
| 721 | } |
| 722 | } |
| 723 | _setUpEvents() { |
| 724 | this._boundDropHandler = this._dropHandler.bind(this); |
| 725 | this._boundDragoverHandler = this._dragoverHandler.bind(this); |
| 726 | this.addEventListener('drop', this._boundDropHandler, false); |
| 727 | this.addEventListener('dragover', this._boundDragoverHandler, false); |
| 728 | this.addEventListener( |
| 729 | 'change', |
| 730 | function (e) { |
| 731 | if (e.target.tagName === 'MAP-LAYER' || e.target.tagName === 'LAYER-') { |
| 732 | this.dispatchEvent( |
| 733 | new CustomEvent('layerchange', { |
| 734 | details: { target: this, originalEvent: e } |
| 735 | }) |
| 736 | ); |
| 737 | } |
| 738 | }, |
| 739 | false |
| 740 | ); |
| 741 | |
| 742 | let host = |
| 743 | this.getRootNode() instanceof ShadowRoot |
| 744 | ? this.getRootNode().host |
| 745 | : this.parentElement; |
| 746 | host.addEventListener('keyup', function (e) { |
| 747 | if ( |
| 748 | e.keyCode === 9 && |
| 749 | document.activeElement.className === 'mapml-web-map' |
| 750 | ) { |
| 751 | // document.activeElement is div.mapml-web-map, not <map> |
| 752 | document.activeElement.dispatchEvent( |
| 753 | new CustomEvent('mapfocused', { detail: { target: this } }) |
| 754 | ); |
| 755 | } |
| 756 | }); |
| 757 | // pasting map-layer, links and geojson using Ctrl+V |
| 758 | this.addEventListener('keydown', function (e) { |
| 759 | if (e.keyCode === 86 && e.ctrlKey) { |
| 760 | navigator.clipboard.readText().then((layer) => { |
| 761 | Util._pasteLayer(this, layer); |
| 762 | }); |
| 763 | // Prevents default spacebar event on all of web-map |
| 764 | } else if ( |
| 765 | e.keyCode === 32 && |
| 766 | document.activeElement.shadowRoot.activeElement.nodeName !== 'INPUT' |
| 767 | ) { |
| 768 | e.preventDefault(); |
| 769 | this._map.fire('keypress', { originalEvent: e }); |
| 770 | } |
| 771 | }); |
| 772 | host.addEventListener('mousedown', function (e) { |
| 773 | if (document.activeElement.className === 'mapml-web-map') { |
| 774 | document.activeElement.dispatchEvent( |
| 775 | new CustomEvent('mapfocused', { detail: { target: this } }) |
| 776 | ); |
| 777 | } |
| 778 | }); |
| 779 | |
| 780 | this._map.on( |
no test coverage detected