Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.
Post by giovanni-cortinovis
bedo2991 wrote:I'm thinking about adding a visualization for speed limits.
What do you think about it? Any suggestion?
Like this: "Via Cassanese [70]"? ;)
giovanni-cortinovis
Waze Global Champs
Waze Global Champs
Posts: 1216
Has thanked: 233 times
Been thanked: 221 times
Send a message
Giovanni
CM: Italy, Cameroon, CAR, Chad, Congo, DR Congo, Gabon, Guinea
https://s.waze.tools/gc.png https://s.waze.tools/lcit.png https://s.waze.tools/c6s.png

Post by Glodenox
And at the same time it would probably be best to wrap the whole script inside a function to prevent a collision of function names or variables with other scripts (which seems very likely due to the very generic function names). It's not that hard to do as it won't impact your script:

Code: Select all

(function() {
  // All function and variable declarations go in here as they are now
})();
For the console issue, I personally use a different function for that:

Code: Select all

function log(obj) {
  if (localStorage.svlDebug) { // just a suggestion, feel free to do something else
    console.log(obj);
  }
}
Also, there is a global variable svlAttempts that could be put as a var at the top of the script as it is not useful anywhere else (inside the function declaration I showed in this post). The risk of a collision with other scripts is very minimal though.

Just trying to make your script even better :)
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Glodenox
As of Firefox version 44 (currently in beta) it is not allowed to assign a value to unsafeWindow (as it is an undefined constant for some reason). I'm currently checking some of the scripts in the forum to make sure they won't break once Firefox 44 goes live (January 26). I've checked your userscript and it uses unsafeWindow a bit, so you may run into problems. Either way, the code below won't do anything useful any more as this way of retrieving the unsafeWindow has been removed. I've seen other scripts just using unsafeWindow without that check and they seem to run fine.

Code: Select all

    var bGreasemonkeyServiceDefined = false;

    try {
        bGreasemonkeyServiceDefined = (typeof Components.interfaces.gmIGreasemonkeyService === "object");
    } catch (err) { /* Ignore */ }

    if (typeof unsafeWindow === "undefined" || !bGreasemonkeyServiceDefined) {
        unsafeWindow = (function() {
            var dummyElem = document.createElement('p');
            dummyElem.setAttribute('onclick', 'return window;');
            return dummyElem.onclick();
        })();
    }
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Glodenox
I've already proposed some changes in the talk page of that article. I'll discuss this further with Timbones first before making any changes there.
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Glodenox
Informational message: Street Vector Layer refers to W.selectionManager.hasSelectedItems, which will be removed in a future version. I see that the script tries to use W.selectionManager.hasSelectedFeatures first, so this script won't run any issues at any time. But feel free to remove the reference to that method as it will trigger a deprecation log message.
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Glodenox
I'm not certain how the first remark is relevant for Street Vector Layer?

Ideally the copyright notice should just be hidden underneath the controls on the right.

For this to happen now, the object with CSS class olControlAttribution must have the CSS property value "right" increased whenever a script author adds a control there. By default the code assumes that the controls to the right of the attribution text will not take up more space than 250 pixels, but that is already too low from the start as that should be 300 pixels. I'll create a bug report about that in the beta forum. Ideally Waze should use the flex layout there to get a consistent layout in all screen sizes, which would also have the advantage that script authors can safely add controls there without having to do anything special.
attribution-ellipsis.jpg
(13.06 KiB) Downloaded 503 times
Glodenox
Waze Global Champs
Waze Global Champs
Posts: 1568
Answers: 1
Has thanked: 278 times
Been thanked: 946 times
Send a message
Belgium & Luxembourg Coordinator • Script Writing Community Coordinator
https://www.tomputtemans.com/images/WazeBelgium.pnghttps://www.tomputtemans.com/images/WazeWMEbeta.png

Post by Gluek
Wow, very nice script, thanks from Russian editors community :)
Gluek
Posts: 486
Has thanked: 96 times
Been thanked: 90 times
Send a message
Группа Waze Russia в Slack | Группа @WazeRussia в Telegram и канал новостей @WazeNews

INTL server updates Telegram bot: @WazeUpdatesBot

Post by Grid64
I feel dumb for just finding this script. :lol:

Amazing!!! I love it.
Grid64
Map Editor - level 3
Map Editor - level 3
Posts: 363
Has thanked: 174 times
Been thanked: 7 times
Send a message

Post by Grid64
Hmmm it might be because of my work computer but I noticed the formatting I see with other scripts is not present with the most recent update. Formatting where everything has the proper carriage returns and line breaks. I'm comparing the script from the new repository to what you added to github and there's proper formatting on what is provided on github.

Hmmmm, I'm going to poke at this more. It might be how Tampermonkey is interpreting the js file or most likely my work filter. I'll see if I run into this on my home computer later.

EDIT: It seems I got to install it with the proper formatting via github. :?
Grid64
Map Editor - level 3
Map Editor - level 3
Posts: 363
Has thanked: 174 times
Been thanked: 7 times
Send a message

Post by herrchin
bedo2991, thank you so much, Vector is awesome!

I have two bugfixes, and I also made some customizations that USA editors may like, as it is geared towards common USA speeds, and also tweaks the label visibility a bit.

Line 254, I replace the getColorSpeed() function with one that uses a tweaked color scale so roads that speed up / slow down only 10 mph have more visual distinction between the colors used:

Code: Select all

function getColorSpeed(speed)
{
    if(W.prefs.attributes.isImperial) // adjust scale for Imperial
    {        
        // speeds 15 to 75 mph (7 increments) are tuned to HSL 95 to 395 (35) for easy visual speed differentiation at common speeds
        return ((speed / 1.609344 * 5) + 20) %360
    }
    else
    {
        return (speed * 3) %360; // :150 * 450
    }
}
Lines 377-379 (now lines 385-387 if you replaced the above function; I will put future line # changes in () as well, for those adopting all changes), there's a typo in "isImperial". The calls to getColorSpeed() for mph also won't have the right colors returned (in both the original and updated function), as it expects to be passed kph. Replace lines 377-379 (385-387) with these 5 to pass kph values in all cases, and to adjust the scale when using mph:

Code: Select all

    for(var k=W.prefs.attributes.isImperial?9:15; k>1; k--){
        if (W.prefs.attributes.isImperial)
	     { $speedLimits.append($('<span style="color:hsl('+getColorSpeed((k*10-5)*1.609344)+',100%,50%)">'+(k*10-5)+' </span>')); }
        else { $speedLimits.append($('<span style="color:hsl('+getColorSpeed(k*10)+',100%,50%)">'+k*10+' </span>')); }
    }
Line 666 (676): I make the fonts bigger for my old man eyes :)

Code: Select all

labelFontSize = farZoom?"14px":"16px";
Line 1232 (1242): Insert a new line after "if(speed)" to add in a visual separator between the street name and the speed limits (as you'll see with the remaining changes, I make the speed limits larger in size)

Code: Select all

speedPart += ": ";
Lines 1234, 1239, and 1247 (now 1245, 1250, and 1258):
Change all "=" to be "+="

Starting at Line 1308 (1319).
Comment out all "number.replace" lines by placing // at the front of each line. Be sure to leave the "number.toString" line alone

Results showing 25 through 65mph colors:
herrchin
Country Manager
Country Manager
Posts: 333
Has thanked: 199 times
Been thanked: 161 times
Send a message