WME Aerial Shifter

This script helps you adjust the position and opacity of underlying satellite imagery

  1. // ==UserScript==
  2. // @name WME Aerial Shifter
  3. // @version 1.6.5
  4. // @description This script helps you adjust the position and opacity of underlying satellite imagery
  5. // @match https://editor-beta.waze.com/*editor/*
  6. // @match https://www.waze.com/*editor/*
  7. // @exclude https://www.waze.com/*user/*editor/*
  8. // @grant none
  9. // @icon http://s3.amazonaws.com/uso_ss/icon/176646/large.png?1391605696
  10. // @namespace https://www.waze.com/forum/viewtopic.php?t=53022
  11. // @author byo
  12. // @contributor berestovskyy
  13. // @contributor iainhouse
  14. // @contributor ragacs
  15. // ==/UserScript==
  16. /*
  17.  
  18. This program is free software: you can redistribute it and/or modify
  19. it under the terms of the GNU General Public License as published by
  20. the Free Software Foundation, either version 3 of the License, or
  21. (at your option) any later version.
  22.  
  23. This program is distributed in the hope that it will be useful,
  24. but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. GNU General Public License for more details.
  27.  
  28. You should have received a copy of the GNU General Public License
  29. along with this program. If not, see <http://www.gnu.org/licenses/>.
  30.  
  31. */
  32.  
  33. (function()
  34. {
  35. var version = "1.6";
  36. var WM;
  37.  
  38. var prefix = 'WAS_';
  39. var settings = prefix + 'settings';
  40.  
  41. var sx, sy, so;
  42.  
  43. function init()
  44. {
  45. // init shortcuts
  46. if(!(WM = window.Waze.map) || !$('#search').length)
  47. {
  48. window.console.log("WME Aerial Shifter v" + version
  49. + ": waiting for WME...");
  50. setTimeout(init, 500);
  51. return;
  52. }
  53.  
  54. var suffix = ' of satellite imagery';
  55. var psx = prefix + 'sx', psy = prefix + 'sy', pso = prefix + 'so',
  56. psr = prefix + 'reset';
  57.  
  58. var nav = $(
  59. '<div style="direction:ltr;text-align:right;color:white;width:420px;'
  60. + 'line-height:20px;position:absolute;right:10px;top:52px">'
  61. + '<label title="Horizontal shift' + suffix + ' (meters)"'
  62. + 'style="font-weight:normal" for="' + psx + '">'
  63. + '<i class="fa fa-arrow-right"></i> '
  64. + '<input type="number" max="100" min="-100" step="10"'
  65. + 'style="text-align:right;width:60px;height:25px;padding:0 5px"'
  66. + 'id="' + psx + '" value="0"/>'
  67. + ' m'
  68. + '</label>'
  69. + ' &nbsp; '
  70. + '<label title="Vertical shift' + suffix + ' (meters)"'
  71. + 'style="font-weight:normal" for="' + psy + '">'
  72. + '<i class="fa fa-arrow-down"></i> '
  73. + '<input type="number" max="100" min="-100" step="10"'
  74. + 'style="text-align:right;width:60px;height:25px;padding:0 5px"'
  75. + 'id="' + psy + '" value="0"/>'
  76. + ' m'
  77. + '</label>'
  78. + ' &nbsp; '
  79. + '<label title="Opacity' + suffix + ' (pecent)"'
  80. + 'style="font-weight:normal" for="' + pso + '">'
  81. + '<i class="fa fa-adjust"></i> '
  82. + '<input type="number" max="100" min="0" step="25"'
  83. + 'style="text-align:right;width:55px;height:25px;padding:0 5px"'
  84. + 'id="' + pso + '" value="100"/>'
  85. + ' %'
  86. + '</label>'
  87. + ' &nbsp; '
  88. + '<a id="' + psr + '" style="color:white;text-decoration:none"'
  89. + 'href="#" title="Reset defaults">'
  90. + '<i class="fa fa-undo"></i>'
  91. + '</a>'
  92. + ' | '
  93. + '<a target="_blank" style="color:white;text-decoration:none"'
  94. + 'href="https://www.waze.com/forum/viewtopic.php?t=53022"'
  95. + 'title="WME Aerial Shifter v' + version + '">'
  96. + '<i class="fa fa-question"></i>'
  97. + '</a>'
  98. + '</div>'
  99. );
  100. sx = nav.find('#' + psx);
  101. sy = nav.find('#' + psy);
  102. so = nav.find('#' + pso);
  103. if($('#header-actions').length)
  104. $('#header-actions').append(nav);
  105. else
  106. {
  107. nav.css('right', '');
  108. nav.css('top', '');
  109. nav.css('left', 0);
  110. nav.css('padding-top', 6);
  111. nav.css('position', 'relative');
  112. $('#search').after(nav);
  113. }
  114.  
  115. loadFromStorage();
  116. update();
  117.  
  118. WM.events.on({
  119. zoomend : update,
  120. moveend : update
  121. });
  122. WM.baseLayer.events.on({
  123. loadend : update,
  124. });
  125. sx.change(update);
  126. sy.change(update);
  127. so.change(update);
  128. nav.find('#' + psr).click(resetDefaults);
  129. }
  130.  
  131. function resetDefaults()
  132. {
  133. sx.val(0);
  134. sy.val(0);
  135. so.val(100);
  136.  
  137. update();
  138. }
  139.  
  140. function loadFromStorage()
  141. {
  142. var obj = JSON.parse(localStorage.getItem(settings));
  143. if(obj)
  144. {
  145. sx.val(obj.sx);
  146. sy.val(obj.sy);
  147. so.val(obj.so);
  148. }
  149. }
  150.  
  151. function saveToStorage()
  152. {
  153. localStorage.setItem(settings, JSON.stringify({
  154. sx: sx.val(),
  155. sy: sy.val(),
  156. so: so.val(),
  157. }));
  158. }
  159.  
  160. function update()
  161. {
  162. // calculate meters per pixel factor of current map
  163. window.console.log("Up!");
  164. var ipu = OpenLayers.INCHES_PER_UNIT;
  165. var metersPerPixel = WM.getResolution() * ipu['m']
  166. / ipu[WM.getUnits()];
  167. var shiftX = parseInt(sx.val(), 10);
  168. var shiftY = parseInt(sy.val(), 10);
  169. var opacity = parseInt(so.val(), 10);
  170.  
  171. // Apply the shift and opacity
  172. WM.baseLayer.div.style.left =
  173. Math.round(shiftX / metersPerPixel) + 'px';
  174. WM.baseLayer.div.style.top =
  175. Math.round(shiftY / metersPerPixel) + 'px';
  176. WM.baseLayer.div.style.opacity = opacity/100;
  177.  
  178. saveToStorage();
  179. }
  180.  
  181. init();
  182. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址