WME Clear Geometry

Temporary script to hook "1" for clearing geometry until Toolbox is fixed

  1. // ==UserScript==
  2. // @name WME Clear Geometry
  3. // @namespace https://gf.qytechs.cn/users/30701-justins83-waze
  4. // @version 0.8
  5. // @description Temporary script to hook "1" for clearing geometry until Toolbox is fixed
  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.  
  19. (function() {
  20.  
  21. var UpdateSegmentGeometry;
  22.  
  23. function bootstrap(tries = 1) {
  24.  
  25. if (W &&
  26. W.map &&
  27. W.model &&
  28. require &&
  29. WazeWrap.Interface &&
  30. $) {
  31. init();
  32. } else if (tries < 1000) {
  33. setTimeout(function () {bootstrap(tries++);}, 200);
  34. }
  35. }
  36.  
  37. bootstrap();
  38.  
  39. function init(){
  40. UpdateSegmentGeometry = require('Waze/Action/UpdateSegmentGeometry');
  41.  
  42. new WazeWrap.Interface.Shortcut('clearGeomShortcut', 'Clears road geometry', 'editing', 'Editing', '1', ClearGeometry, this).add();
  43.  
  44. }
  45.  
  46. function ClearGeometry(){
  47. if (W.selectionManager.getSelectedFeatures().length !== 0) {
  48. for (i = 0; i < W.selectionManager.getSelectedFeatures().length; i++) {
  49. var seg = W.selectionManager.getSelectedFeatures()[i].model;
  50. if (seg.type == "segment") {
  51. var newGeo = seg.geometry.clone();
  52. newGeo.components.splice(1, newGeo.components.length - 2);
  53. newGeo.components[0].calculateBounds();
  54. newGeo.components[1].calculateBounds();
  55. W.model.actionManager.add(new UpdateSegmentGeometry(seg, seg.geometry, newGeo));
  56. }
  57. }
  58. }
  59. }
  60. })();

QingJ © 2025

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