WME OH Scripts

Recommended scripts for editing in Ohio

  1. // ==UserScript==
  2. // @name WME OH Scripts
  3. // @namespace https://gf.qytechs.cn/users/30701-justins83-waze
  4. // @version 2021.06.19.01
  5. // @description Recommended scripts for editing in Ohio
  6. // @include https://www.waze.com/editor*
  7. // @include https://www.waze.com/*/editor*
  8. // @include https://beta.waze.com/*
  9. // @exclude https://www.waze.com/user/editor*
  10. // @author JustinS83
  11. // @grant none
  12. // @require https://gf.qytechs.cn/scripts/24851-wazewrap/code/WazeWrap.js
  13. // @license GPLv3
  14. // ==/UserScript==
  15.  
  16. /* global W */
  17. /* global WazeWrap */
  18. /* global $ */
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. // Your code here...
  24. function bootstrap(tries = 1) {
  25. if (W &&
  26. W.map &&
  27. W.model &&
  28. WazeWrap.Ready &&
  29. $) {
  30. init();
  31. } else if (tries < 1000) {
  32. setTimeout(function () {bootstrap(++tries);}, 200);
  33. }
  34. }
  35.  
  36. bootstrap();
  37.  
  38. function isChecked(id) {
  39. return $('#' + id).is(':checked');
  40. }
  41.  
  42. function setChecked(id, checked) {
  43. $('#' + id).prop('checked', checked);
  44. }
  45.  
  46. function init(){
  47. var $section = $("<div>", {style:"padding:8px 16px", id:"OHScriptsSettings"});
  48. $section.html([
  49. '<p>',
  50. '<div><a href="https://www.waze.com/forum/viewforum.php?f=943" target="_blank">Great Lakes Region forum</a></br>',
  51. '<a href="https://www.waze.com/forum/viewforum.php?f=261" target="_blank">Ohio forum</a></br>',
  52. '<a href="https://wazeopedia.waze.com/wiki/USA/Ohio" target="_blank">Ohio wiki</a>',
  53. '</div>',
  54. '<hr>',
  55. '<div title="OH Validator Localization, Author: Xanderb" id="divOHValidatorLocalization" class="controls-container"><input type="checkbox" id="_cbOHValidatorLocalizationEnable" /><label for="_cbOHValidatorLocalizationEnable">OH Validator Localization <a href="https://gf.qytechs.cn/en/scripts/8746-wme-validator-localization-for-ohio" target="_blank">...</a></label></div>',
  56. '<div title="OH Counties 2014, Author: rickzable" class="controls-container"><input type="checkbox" id="_cbOHCounties2014Enable" /><label for ="_cbOHCounties2014Enable"> OH Counties 2014 <a href="https://gf.qytechs.cn/en/scripts/26450-wme-counties-ohio-census-2014-justins83-fork" target="_blank">...</a></label></div>',
  57. '<div title="OH Cities 2014-1, Author: JustinS83" class="controls-container"><input type="checkbox" id="_cbOHCities20141Enable" /><label for ="_cbOHCities20141Enable"> OH Cities 2014-1 <a href="https://gf.qytechs.cn/scripts/17391-wme-ohio-cities-census-2014-1" target="_blank">...</a></label></div>',
  58. '<div title="OH Cities 2014-2, Author: JustinS83" class="controls-container"><input type="checkbox" id="_cbOHCities20142Enable" /><label for ="_cbOHCities20142Enable"> OH Cities 2014-2 <a href="https://gf.qytechs.cn/scripts/17392-wme-ohio-cities-census-2014-2" target="_blank">...</a></label></div>',
  59. '<hr>',
  60. '<div class="controls-container"><button type="button" id="_btnLoadTIMS">Open in TIMS</button><input type="radio" style="display:block" name="TIMSOptions" id="FCDisplay" /><label for="FCDisplay" title="Function Classification Display">FC Display</label><input type="radio" style="display:block" name="TIMSOptions" id="CRDisplay"/><label for="CRDisplay" title="County Road Display">CR Display</label></div>',
  61. '<div class="controls-container"><button type="button" id="_btnOpenGMM">Open in Google Maps</button></div>',
  62. '<div class="controls-container"><button type="button" id="_btnOpenCAGIS">Open in CAGIS</button></div>',
  63. '</p>'
  64. ].join(' '));
  65. new WazeWrap.Interface.Tab('OH Scripts', $section.html(), initializeSettings);
  66. }
  67.  
  68. function CAGISButtonClick(){
  69. //http://www.arcgis.com/apps/webappviewer/index.html?center=-84.38982,39.16987,4326&extent=1432531.5982,431576.3841,1432984.2024,431800.3424,102723
  70. var center_lonlat = WazeWrap.Geometry.ConvertTo4326(W.map.getCenter().lon, W.map.getCenter().lat);
  71. var TopLeft, BottomRight;
  72. var extent = W.map.getExtent();
  73. TopLeft = WazeWrap.Geometry.ConvertTo4326(extent.left, extent.bottom);
  74. BottomRight = WazeWrap.Geometry.ConvertTo4326(extent.right, extent.top);
  75. var lat = Math.round(center_lonlat.lat * 1000000) / 1000000;
  76. var lon = Math.round(center_lonlat.lon * 1000000) / 1000000;
  77. window.open('http://www.arcgis.com/apps/webappviewer/index.html?center=' + lon + ',' + lat + ',4326&extent=' + TopLeft.lon + ',' + TopLeft.lat + ',' + BottomRight.lon + ',' + BottomRight.lat + ',4326', 'CAGIS');
  78. }
  79.  
  80. function GMMButtonClick(){
  81. var center_lonlat = WazeWrap.Geometry.ConvertTo4326(W.map.getCenter().lon, W.map.getCenter().lat);
  82. var lat = Math.round(center_lonlat.lat * 1000000) / 1000000;
  83. var lon = Math.round(center_lonlat.lon * 1000000) / 1000000;
  84. console.log(center_lonlat);
  85. window.open('https://www.google.com/maps/@' + lat + ',' + lon + ',' +( W.map.zoom + 12) + 'z', 'Google Maps');
  86. }
  87.  
  88. function TIMSButtonClick(){
  89. var center_lonlat = WazeWrap.Geometry.ConvertTo4326(W.map.getCenter().lon, W.map.getCenter().lat);
  90. var topleft = WazeWrap.Geometry.ConvertTo4326(W.map.getExtent().left, W.map.getExtent().top);
  91. var bottomright = WazeWrap.Geometry.ConvertTo4326(W.map.getExtent().right, W.map.getExtent().bottom);
  92. var lat = Math.round(center_lonlat.lat * 1000000) / 1000000;
  93. var lon = Math.round(center_lonlat.lon * 1000000) / 1000000;
  94. var spn = Math.abs(topleft.lat - bottomright.lat) + ',' + Math.abs(topleft.lon - bottomright.lon);
  95. var newZoom = (W.map.zoom + 12);
  96. if($('#FCDisplay').is(':checked')) //FC display
  97. window.open('https://gis.dot.state.oh.us/tims/map?center=' + lon + ',' + lat + '&level=' + newZoom + '&visiblelayers=odot-osip-1:0,1%7Codot-osip-2:0,3%7CAssets:-1%7CBoundaries:2%7CEnvironmental:-1%7CProjects:-1%7CRoadway%20Information:9%7CStrategic%20Transportation%20System:-1%7CSafety:-1', 'ODOT TIMS');
  98. else //CR display
  99. window.open('https://gis.dot.state.oh.us/tims/map?center=' + lon + ',' + lat + '&level=' + newZoom + '&visiblelayers=Assets:-1|Environmental:-1|Projects:-1|Roadway%20Information:8|Strategic%20Transportation%20System:-1','ODOT TIMS');
  100. }
  101.  
  102. function initializeSettings(){
  103. var storedOptionsStr = localStorage.GLR_OHScripts;
  104.  
  105. if(!localStorage.GLR_OHScripts)
  106. storedOptionsStr = localStorage.OHScripts;
  107.  
  108. var options = storedOptionsStr ? JSON.parse(storedOptionsStr) : [0, true, true, false, false, true];
  109. setChecked('_cbOHValidatorLocalizationEnable', options[1]);
  110. setChecked('_cbOHCounties2014Enable', options[2]);
  111. setChecked('_cbOHCities20141Enable', options[3]);
  112. setChecked('_cbOHCities20142Enable', options[4]);
  113.  
  114. if(!localStorage.GLR_OHScripts){
  115. SaveSettings();
  116. localStorage.removeItem("OHScripts");
  117. }
  118.  
  119. if(options[5])
  120. setChecked('FCDisplay', true);
  121. else
  122. setChecked('CRDisplay', true);
  123.  
  124. $('input[id^="_cbOH"]').change(function() { SaveSettings(); });
  125. $('input[id^="_cbOH"]').change(function() {
  126. var layerName = "";
  127. if(this.id === "_cbOHCities20141Enable"){
  128. if(this.checked){
  129. if(!W.map.getLayerByUniqueName('__OhioCities1'))
  130. $.getScript("https://gf.qytechs.cn/scripts/17391-wme-ohio-cities-census-2014-1/code/WME%20Ohio%20Cities%20Census%202014%20-%201.user.js");
  131. else
  132. toggleLayerVisible('__OhioCities1', true);
  133. }
  134. else{
  135. toggleLayerVisible('__OhioCities1', false);
  136. }
  137. }
  138. else if(this.id === "_cbOHCities20142Enable"){
  139. if(this.checked){
  140. if(!W.map.getLayerByUniqueName('__OhioCities2'))
  141. $.getScript("https://gf.qytechs.cn/scripts/17392-wme-ohio-cities-census-2014-2/code/WME%20Ohio%20Cities%20Census%202014%20-%202.user.js");
  142. else
  143. toggleLayerVisible('__OhioCities2', true);
  144. }
  145. else{
  146. toggleLayerVisible('__OhioCities2', false);
  147. }
  148. }
  149. else if(this.id === "_cbOHCounties2014Enable"){
  150. if(this.checked){
  151. if(!W.map.getLayerByUniqueName('__Ohio'))
  152. $.getScript("https://gf.qytechs.cn/scripts/26450-wme-counties-ohio-census-2014-justins83-fork/code/WME%20Counties%20Ohio%20Census%202014%20(JustinS83%20fork).user.js");
  153. else
  154. toggleLayerVisible('__Ohio', true);
  155. }
  156. else{
  157. toggleLayerVisible('__Ohio', false);
  158. }
  159. }
  160. });
  161.  
  162. $('#FCDisplay').change(function() { SaveSettings(); });
  163. $('#CRDisplay').change(function() { SaveSettings(); });
  164. $('#_btnLoadTIMS').click(TIMSButtonClick);
  165. $('#_btnOpenGMM').click(GMMButtonClick);
  166. $('#_btnOpenCAGIS').click(CAGISButtonClick);
  167.  
  168. if(options[1])
  169. $.getScript("https://gf.qytechs.cn/scripts/8746-wme-validator-localization-for-ohio/code/WME%20Validator%20Localization%20for%20Ohio.user.js");
  170.  
  171. if(options[2])
  172. $.getScript("https://gf.qytechs.cn/scripts/26450-wme-counties-ohio-census-2014-justins83-fork/code/WME%20Counties%20Ohio%20Census%202014%20(JustinS83%20fork).user.js");
  173.  
  174. if(options[3]){
  175. if(!W.map.getLayerByUniqueName('__OhioCities1')){
  176. $.getScript("https://gf.qytechs.cn/scripts/17391-wme-ohio-cities-census-2014-1/code/WME%20Ohio%20Cities%20Census%202014%20-%201.user.js");
  177. //W.map.getLayerByUniqueName('__OhioCities1').displayInLayerSwitcher = false;
  178. }
  179. }
  180.  
  181. if(options[4]){
  182. if(!W.map.getLayerByUniqueName('__OhioCities1')){
  183. $.getScript("https://gf.qytechs.cn/scripts/17392-wme-ohio-cities-census-2014-2/code/WME%20Ohio%20Cities%20Census%202014%20-%202.user.js");
  184. //W.map.getLayerByUniqueName('__OhioCities2').displayInLayerSwitcher = false;
  185. }
  186. }
  187. }
  188.  
  189. function toggleLayerVisible(layerName, visible){
  190. if(visible)
  191. W.map.getLayerByUniqueName(layerName).div.style.display = 'block';
  192. else
  193. W.map.getLayerByUniqueName(layerName).div.style.display = 'none';
  194. W.map.getLayerByUniqueName(layerName).visibility = visible;
  195. }
  196.  
  197. function SaveSettings(){
  198. if (localStorage) {
  199. var options = [];
  200. // preserve previous options which may get lost after logout
  201. if (localStorage.GLR_OHScripts) { options = JSON.parse(localStorage.GLR_OHScripts); }
  202. options[1] = isChecked('_cbOHValidatorLocalizationEnable');
  203. options[2] = isChecked('_cbOHCounties2014Enable');
  204. options[3] = isChecked('_cbOHCities20141Enable');
  205. options[4] = isChecked('_cbOHCities20142Enable');
  206. options[5] = isChecked('FCDisplay');
  207. localStorage.GLR_OHScripts = JSON.stringify(options);
  208. }
  209. }
  210. })();

QingJ © 2025

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