MCPcopy Index your code
hub / github.com/Maps4HTML/MapML.js / _setUpEvents

Method _setUpEvents

src/mapml-viewer.js:681–1006  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

679 }
680 }
681 _setUpEvents() {
682 this._boundDropHandler = this._dropHandler.bind(this);
683 this._boundDragoverHandler = this._dragoverHandler.bind(this);
684 this.addEventListener('drop', this._boundDropHandler, false);
685 this.addEventListener('dragover', this._boundDragoverHandler, false);
686 this.addEventListener(
687 'change',
688 function (e) {
689 if (e.target.tagName === 'MAP-LAYER' || e.target.tagName === 'LAYER-') {
690 this.dispatchEvent(
691 new CustomEvent('layerchange', {
692 details: { target: this, originalEvent: e }
693 })
694 );
695 }
696 },
697 false
698 );
699
700 let host =
701 this.getRootNode() instanceof ShadowRoot
702 ? this.getRootNode().host
703 : this.parentElement;
704 host.addEventListener('keyup', function (e) {
705 if (
706 e.keyCode === 9 &&
707 document.activeElement.nodeName === 'MAPML-VIEWER'
708 ) {
709 document.activeElement.dispatchEvent(
710 new CustomEvent('mapfocused', { detail: { target: this } })
711 );
712 }
713 });
714 // pasting map-layer, links and geojson using Ctrl+V
715 this.addEventListener('keydown', function (e) {
716 if (e.keyCode === 86 && e.ctrlKey) {
717 navigator.clipboard.readText().then((layer) => {
718 Util._pasteLayer(this, layer);
719 });
720 // Prevents default spacebar event on all of mapml-viewer
721 } else if (
722 e.keyCode === 32 &&
723 this.shadowRoot.activeElement.nodeName !== 'INPUT'
724 ) {
725 e.preventDefault();
726 this._map.fire('keypress', { originalEvent: e });
727 }
728 });
729 host.addEventListener('mousedown', function (e) {
730 if (document.activeElement.nodeName === 'MAPML-VIEWER') {
731 document.activeElement.dispatchEvent(
732 new CustomEvent('mapfocused', { detail: { target: this } })
733 );
734 }
735 });
736
737 this._map.on(
738 'locationfound',

Callers 1

_createMapMethod · 0.95

Calls 6

_updateMapCenterMethod · 0.95
_addToHistoryMethod · 0.95
whenLayersReadyMethod · 0.95
reloadMethod · 0.95
forwardMethod · 0.95
backMethod · 0.95

Tested by

no test coverage detected