Enlarge Segment Geo Handles

Enlarges the geometry handles on segments so they are easier to find

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name         Enlarge Segment Geo Handles
// @namespace    https://greasyfork.org/users/30701-justins83-waze
// @description  Enlarges the geometry handles on segments so they are easier to find
// @version      2023.03.21.01
// @author       JustinS83
// @include      https://www.waze.com/editor*
// @include      https://www.waze.com/*/editor*
// @include      https://beta.waze.com/editor*
// @include      https://beta.waze.com/*/editor*
// @exclude      https://www.waze.com/user/editor*
// @grant        none
// @require      https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// ==/UserScript==

/* global W */
/* global WazeWrap */
/* global $ */

(function() {
    'use strict';

    function bootstrap(tries = 1) {
        if (W &&
            W.map &&
            W.model &&
            W.loginManager.user &&
            $ &&
            WazeWrap.Ready)
            init();
        else if (tries < 1000)
            setTimeout(function () {bootstrap(++tries);}, 200);
    }

    function init(){
        registerEvents(changeGeoHandleStyle);
    }

    function changeGeoHandleStyle(){
        if(WazeWrap.hasSegmentSelected()){
            setTimeout(function(){
                let controls = W.map.controls.find((c) => c.dragControl != null); //W.map.controls.find((c) => c.displayClass === "WazeControlModifyFeatureSegment");
                let rules = controls.sketchLayer.styleMap.styles.default.rules;
                debugger;
                for(let i=0; i< rules.length; i++){
                    if(rules[i].id === "OpenLayers_Rule_5"){ //2023-03-21 was Rule_30
                        rules[i].symbolizer.pointRadius = 8;
                        break;
                    }
                }
                controls.resetVertices()
                unregisterEvents(changeGeoHandleStyle);
            },100);
        }
    }

    function registerEvents(handler){
        WazeWrap.Events.register("selectionchanged", null, handler);
        WazeWrap.Events.register("afterundoaction",null, handler);
        WazeWrap.Events.register("afterclearactions",null, handler);
        WazeWrap.Events.register("afteraction",null, handler);
    }

    function unregisterEvents(handler){
        WazeWrap.Events.unregister("selectionchanged", null, handler);
        WazeWrap.Events.unregister("afterundoaction",null, handler);
        WazeWrap.Events.unregister("afterclearactions",null, handler);
        WazeWrap.Events.unregister("afteraction",null, handler);
    }

    bootstrap();
})();