|
3696 | 3696 | text:"Toggle Debug Mode (<kbd>D</kbd>)", |
3697 | 3697 | callback:this._toggleDebug, |
3698 | 3698 | }, |
| 3699 | + { |
| 3700 | + text:"Copy MapML (<kbd>M</kbd>)", |
| 3701 | + callback:this._copyMapML, |
| 3702 | + }, |
3699 | 3703 | { |
3700 | 3704 | text:"View Map Source (<kbd>V</kbd>)", |
3701 | 3705 | callback:this._viewSource, |
|
3740 | 3744 |
|
3741 | 3745 | this._items[6].el = this._createItem(this._container, this._items[6]); |
3742 | 3746 | this._items[7].el = this._createItem(this._container, this._items[7]); |
| 3747 | + this._items[8].el = this._createItem(this._container, this._items[8]); |
3743 | 3748 |
|
3744 | 3749 | this._layerMenu = L.DomUtil.create("div", "mapml-contextmenu mapml-layer-menu", map._container); |
3745 | 3750 | this._layerMenu.style.zIndex = 10001; |
|
3802 | 3807 | tL = layerElem.extent.topLeft.pcrs, |
3803 | 3808 | bR = layerElem.extent.bottomRight.pcrs; |
3804 | 3809 |
|
3805 | | - let data = `top-left-easting,${tL.horizontal}\ntop-left-northing,${tL.vertical}\n`; |
3806 | | - data += `bottom-right-easting,${bR.horizontal}\nbottom-right-northing,${bR.vertical}`; |
3807 | | - |
| 3810 | + let data = `<meta name="extent" content="top-left-easting,${tL.horizontal}, top-left-northing,${tL.vertical}, bottom-right-easting,${bR.horizontal}, bottom-right-northing,${bR.vertical}">`; |
3808 | 3811 | context._copyData(data); |
3809 | 3812 | }, |
3810 | 3813 |
|
|
3833 | 3836 | mapEl._toggleControls(); |
3834 | 3837 | }, |
3835 | 3838 |
|
| 3839 | + _copyMapML: function(e){ |
| 3840 | + let context = e instanceof KeyboardEvent ? this._map.contextMenu : this.contextMenu, |
| 3841 | + mapEl = e instanceof KeyboardEvent?this._map.options.mapEl:this.options.mapEl; |
| 3842 | + context._copyData(mapEl.outerHTML.replace(/<div class="mapml-web-map">.*?<\/div>|<style>\[is="web-map"].*?<\/style>|<style>mapml-viewer.*?<\/style>/gm, "")); |
| 3843 | + }, |
| 3844 | + |
3836 | 3845 | _viewSource: function(e){ |
3837 | 3846 | let mapEl = e instanceof KeyboardEvent?this._map.options.mapEl:this.options.mapEl; |
3838 | 3847 | mapEl.viewSource(); |
|
4074 | 4083 | this._coordMenu.style.display = 'none'; |
4075 | 4084 | this._layerMenu.style.display = 'none'; |
4076 | 4085 | this._map.fire('contextmenu.hide', {contextmenu: this}); |
| 4086 | + setTimeout(() => this._map._container.focus(), 0); |
4077 | 4087 | } |
4078 | 4088 | }, |
4079 | 4089 |
|
|
4129 | 4139 | return size; |
4130 | 4140 | }, |
4131 | 4141 |
|
4132 | | - _debounceKeyDown: function(func, wait, immediate) { |
4133 | | - let timeout; |
4134 | | - let context = this, args = arguments; |
4135 | | - clearTimeout(timeout); |
4136 | | - timeout = setTimeout(function() { |
4137 | | - timeout = null; |
4138 | | - if (!immediate) func.apply(context, args); |
4139 | | - }, wait); |
4140 | | - if (immediate && !timeout) func.apply(context, args); |
4141 | | - }, |
4142 | | - |
4143 | 4142 | _onKeyDown: function (e) { |
4144 | 4143 | if(!this._mapMenuVisible) return; |
4145 | | - this._debounceKeyDown(function(){ |
4146 | | - let key = e.keyCode; |
4147 | | - if(key !== 16 && key!== 9 && !(!this._layerClicked && key === 67) && e.path[0].innerText !== "Copy Coordinates (C) >") |
| 4144 | + |
| 4145 | + let key = e.keyCode; |
| 4146 | + if(key !== 16 && key!== 9 && !(!this._layerClicked && key === 67) && e.path[0].innerText !== "Copy Coordinates (C) >") |
| 4147 | + this._hide(); |
| 4148 | + switch(key){ |
| 4149 | + case 32: //SPACE KEY |
| 4150 | + if(this._map._container.parentNode.activeElement.parentNode.classList.contains("mapml-contextmenu")) |
| 4151 | + this._map._container.parentNode.activeElement.click(); |
| 4152 | + break; |
| 4153 | + case 66: //B KEY |
| 4154 | + this._goBack(e); |
| 4155 | + break; |
| 4156 | + case 67: //C KEY |
| 4157 | + if(this._layerClicked){ |
| 4158 | + this._copyLayerExtent(e); |
| 4159 | + } else { |
| 4160 | + this._copyCoords({ |
| 4161 | + latlng:this._map.getCenter() |
| 4162 | + }); |
| 4163 | + } |
| 4164 | + break; |
| 4165 | + case 68: //D KEY |
| 4166 | + this._toggleDebug(e); |
| 4167 | + break; |
| 4168 | + case 77: //M KEY |
| 4169 | + this._copyMapML(e); |
| 4170 | + break; |
| 4171 | + case 70: //F KEY |
| 4172 | + this._goForward(e); |
| 4173 | + break; |
| 4174 | + case 82: //R KEY |
| 4175 | + this._reload(e); |
| 4176 | + break; |
| 4177 | + case 84: //T KEY |
| 4178 | + this._toggleControls(e); |
| 4179 | + break; |
| 4180 | + case 86: //V KEY |
| 4181 | + this._viewSource(e); |
| 4182 | + break; |
| 4183 | + case 27: //H KEY |
4148 | 4184 | this._hide(); |
4149 | | - switch(key){ |
4150 | | - case 32: //SPACE KEY |
4151 | | - if(this._map._container.parentNode.activeElement.parentNode.classList.contains("mapml-contextmenu")) |
4152 | | - this._map._container.parentNode.activeElement.click(); |
4153 | | - break; |
4154 | | - case 66: //B KEY |
4155 | | - this._goBack(e); |
4156 | | - break; |
4157 | | - case 67: //C KEY |
4158 | | - if(this._layerClicked){ |
4159 | | - this._copyLayerExtent(e); |
4160 | | - } else { |
4161 | | - this._copyCoords({ |
4162 | | - latlng:this._map.getCenter() |
4163 | | - }); |
4164 | | - } |
4165 | | - break; |
4166 | | - case 68: |
4167 | | - this._toggleDebug(e); |
4168 | | - break; |
4169 | | - case 70: |
4170 | | - this._goForward(e); |
4171 | | - break; |
4172 | | - case 82: //R KEY |
4173 | | - this._reload(e); |
4174 | | - break; |
4175 | | - case 84: //T KEY |
4176 | | - this._toggleControls(e); |
4177 | | - break; |
4178 | | - case 86: //V KEY |
4179 | | - this._viewSource(e); |
4180 | | - break; |
4181 | | - case 27: //H KEY |
4182 | | - this._hide(); |
4183 | | - break; |
4184 | | - case 90: //Z KEY |
4185 | | - if(this._layerClicked) |
4186 | | - this._zoomToLayer(e); |
4187 | | - break; |
4188 | | - } |
4189 | | - },250); |
| 4185 | + break; |
| 4186 | + case 90: //Z KEY |
| 4187 | + if(this._layerClicked) |
| 4188 | + this._zoomToLayer(e); |
| 4189 | + break; |
| 4190 | + } |
4190 | 4191 | }, |
4191 | 4192 |
|
4192 | 4193 | _showCoordMenu: function(e){ |
|
0 commit comments