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 Reply
Forum rules
Discussion for the unofficial, community-developed addons, extensions and scripts built for the Waze Map Editor.

DO NOT START a new thread unless it is about a new idea. Keep discussion of existing tools within the main thread for that tool.

The official index of these tools is the Community Plugins, Extensions and Tools wiki page.

[Script] WazeWrap

Post by
Waze Wrap

Current version: 2019.06.12.01

Authors: JustinS83, MapOMatic

Greasyfork: https://greasyfork.org/en/scripts/24851-wazewrap

WazeWrap is intended to be a base library for script writers, filling the roll that wLib started to fill before the author stopped supporting. Originally we intended to extend the wLib script, but the recent WME changes made that impossible since some wLib functionality would need to be updated in order to work properly - so we are starting anew.

The require line will look something like this:

Code: Select all

// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
Once the script is required it can be accessed via WazeWrap. Examples:

Code: Select all

WazeWrap.User.Rank()
will return the current user's normalized rank.

Code: Select all

WazeWrap.User.Username()
will return the current user's username.

Code: Select all

new WazeWrap.Interface.Tab('My Script', <div>Tab info</div>, callbackFunction)
- will create a tab in the side panel with the title "My Script", "Tab info" for html and will call the callbackFunction once the tab is created and html set.

There are currently 5 namespaces that are being developed - Model, Geometry, Interface, Util & User. These can be explored via accessing WazeWrap in the console. Below is the current implementation as of 2017-03-17.

Geometry:

Code: Select all

ConvertTo4326 - converts given 900913 projection coordinates to 4326 projection coordiantes
ConvertTo900913 - converts given 4326 projection coordinates to 900913 coordinates
CalculateLongOffsetGPS - converts a longitudinal offset in meters to an offset in 4326 projection
CalculateLatOffsetGPS - converts a latitudinal offset in meters to an offset in 4326 projection
isLonLatInMapExtent - checks if the given LatLon is in the current map extent
isGeometryInMapExtent - checks if the given OL.Geometry is in the current map extent
calculateDistance - Calculates the distance between the given points (OL.Geometry.Point array) in meters
findClosestSegment - finds the closest segment on screen to the given Ol.Geometry, with options to ignore PLR segments and unnamed PR segments
Model:

Code: Select all

getPrimaryStreetID - Returns the primary street ID for the given segment ID
getStreetName - Returns the street name for the given primary street ID
getCityID - Returns the city ID for the given primary street ID
getStateName - Returns the state name for the given primary street ID
getStateID - Returns the state ID for the given primary street ID
getCountryID - Returns the country ID for the given primary street ID
getCountryName - Returns the country name for the given primary street ID
getCityNameFromSegmentObj - Returns the city name for the given segment object
getStateNameFromSegmentObj - Returns the state name for the given segment object
getAllRoundaboutSegmentsFromObj - Returns an array of segmentIDs for all segments that are part of the same roundabout as the passed segment
getAllRoundaboutJunctionNodesFromObj - Returns an array of segmentIDs for all nodes that are part of the same roundabout as the passed segment
isRoundaboutSegmentID - Checks if the given segment ID is a part of a roundabout
isRoundaboutSegmentObj - Checks if the given segment object is a part of a roundabout
getOnscreenSegments - Returns all onscreen segments
onModelReady - Defers execution of a callback function until the WME map and data model are ready. Call this function before calling a function that causes a map and model reload, such as W.map.moveTo()
RouteSelection - Retrives a route from the Waze Live Map

User:

Code: Select all

Rank - Returns the [b]normalized[/b] rank of the current user
Username - Returns the current user's username
isCM - Returns true if the current user is a Country Manager
isAM - Returns true if the current user is an Area Manager

Require:

Code: Select all

DragElement - Definition of the DragElement class that can be require'd - Waze removed this from the native require
DivIcon - Definition of the DivIcon class that can be required'd - Waze removed this from the native require, but as of 2017-3-14 it is re-instituted natively.

Util:

Code: Select all

waitForElement - Defers execution until the given element is present on the page
mapReady - Returns if a map operation is pending or undefined if the function has not yet seen a map ready event fired.
modelReady - Returns if the model has loaded objects or undefined if the function has not yet seen a model ready event fired

Interface:

Code: Select all

Shortcut - Class for creating a keyboard shortcut in WME.
Tab - Creates a new WazeWrap.Interface.Tab. The tab is appended to the WME editor sidebar and contains the passed HTML content
AddLayerCheckbox - Adds a checkbox to the new Layer menu. The checkbox will be re-added when switching to/from Event mode, and the checked status preserved. If a custom group (not the standard "issues", "places", "road", "display" is passed a new group will be created and the checkbox will be added to it, correctly toggling with the group's checkbox status.
PIN information:
viewtopic.php?p=1970026#p1970026


Changelog:

Code: Select all

2019-06-12 - 2019.06.12.01 - Added an interface for WazeWrap and API for saving/retrieving settings from the server.
2019-04-29 - 2019.04.29.01 - Added Alerts interface
2018-04-10 - 2018.04.10.01 - Added support for WME object changes in beta - new functions support both production and beta WME with changed objects.
2017-11-10 - 2017.11.10.01 - Interface.Tab will now recreate the script's tab when switching between event & edit mode and when the user changes imperial/metric units.
2017-03-16 - AddLayerCheckbox can now handle custom groups (and handles event mode switching and persists the checkbox state between hard refreshes)
2017-03-15 - Support for recovering from changing to/from event mode
2017-03-14 - Added WazeWrap.Interface.AddLayerCheckbox method for adding an item to the new layer list.
2017-01-04 - Added a Require section that allows use of DivIcon and DragElement.

2016-12-01 - Added Geometry.calculateDistance to calculate the total distance for the OL.Geometry.Point array given (minimum 2 points necessary). Started adding method header comments.

2016-11-21 - Checking if loaded in beta editor and if so not applying d2's fix. Latest: version=159287

2016-11-17 - Move the WazeWrap object definition outside of the function so each script using WazeWrap will get the version quested in their require.

2016-11-16 - Added support for wLib's mapReady, modelReady & onModelReady due to request.
 
 
 
 
 
 
 
 

POSTER_ID:17015339

1

Send a message
Last edited by JustinS83 on Tue Apr 10, 2018 6:48 pm, edited 12 times in total.

Post by Inactive user -1697532064-
Wow that's sweet. Thanks!
Inactive user -1697532064-
Wiki Master
Wiki Master
Posts: 1308
Has thanked: 549 times
Been thanked: 703 times
Send a message
Galaxy S20 FE on Mint
Retired SM Ohio
Then you will know the truth, and the truth will set you free.
-John 8:32

Post by ABelter
It appears there may be a typo on line 1953 of WazeWrapLib. This...

Code: Select all

'<wz-toggle-switch class="' + groupClass + ' hydrated" id="' + groupClass + '" + '(groupChecked ? 'checked' : '') + '>',
returns the following console error:
WazeWrapLib.js?_=1599880702404:1953 Uncaught (in promise) TypeError: "" + " is not a function
at CreateParentGroup (WazeWrapLib.js?_=1599880702404:1953)
at Interface.AddLayerCheckbox (WazeWrapLib.js?_=1599880702404:1966)
at init511ReportsOverlay (userscript.html?name=WME%20NCDOT%20Reports.user.js&id=4948143e-cce6-4a84-8a74-f910da4f381d:950)
at initGui (userscript.html?name=WME%20NCDOT%20Reports.user.js&id=4948143e-cce6-4a84-8a74-f910da4f381d:1159)
at init (userscript.html?name=WME%20NCDOT%20Reports.user.js&id=4948143e-cce6-4a84-8a74-f910da4f381d:1255)
I believe the + and ' just prior to groupChecked are just out of order and should be like this:

Code: Select all

'<wz-toggle-switch class="' + groupClass + ' hydrated" id="' + groupClass + '" ' + (groupChecked ? 'checked' : '') + '>',
ABelter
Posts: 68
Has thanked: 30 times
Been thanked: 23 times
Send a message
Andrew aka ABelter
State Manager / North Carolina
Traffic Event Marshal / South Atlantic Region (NC, SC, TN, KY)
andrew@wazenc.us

Post by bedo2991
I found a funny bug, layers names may not contain

Code: Select all

( )
(and maybe other "special" characters).

If they do, the checkbox gets added but the callback function does not get called.
bedo2991
Waze Global Champs
Waze Global Champs
Posts: 2385
Answers: 2
Has thanked: 237 times
Been thanked: 627 times
Send a message

Post by bedo2991
I just wrote it down to avoid someone else in the future to waste some time to find out why it doesn't work, it doesn't need to be fixed (though it could, by sanitizing the string when generating the ID or by splitting the text for the label and the text for the ID as two separate parameters).
bedo2991
Waze Global Champs
Waze Global Champs
Posts: 2385
Answers: 2
Has thanked: 237 times
Been thanked: 627 times
Send a message

Post by bz2012
We have the 'History' icon showing but it doesn't do anything when I click on it (except allow me to move it around).

Also WMEPH and WMEPH-beta have disappeared.
bz2012
Map Raider
Map Raider
Posts: 1622
Has thanked: 1970 times
Been thanked: 305 times
Send a message

Post by crazycaveman
I haven't seen that problem (regarding page never finishing loading) with the new update dialog, editor loads fine whether an update log is shown or not. However, regarding the update log, if there are several scripts that update and produce a scroll bar, I am unable to scroll the list with the mouse (in Chrome and Firefox, have to click and drag the bar). Would it be possible to make the list scrollable with the mouse wheel?
crazycaveman
US Waze Champs
US Waze Champs
Posts: 857
Has thanked: 226 times
Been thanked: 441 times
Send a message

Post by dBsooner
Thank you, Justin! Good stuff! Is the update content capable of being HTML encode?
dBsooner
Map Editor - Level 5
Map Editor - Level 5
Posts: 767
Has thanked: 367 times
Been thanked: 631 times
Send a message
https://s.waze.tools/scrp.pnghttps://s.waze.tools/am.pnghttps://s.waze.tools/betc.pnghttps://s.waze.tools/beta.pnghttps://s.waze.tools/mapr.pnghttps://storage.googleapis.com/wazeopedia-files/7/74/Waze_signature_200k_plain.pnghttps://s.waze.tools/c5s.png
• AM: Eastern Oklahoma, DFW, Southern Florida
• Wiki: WME | Editing Manual | Best Practices | FAQ | Places
• T-Mobile | iPhone 14 Pro | iOS Latest | Waze Latest Beta

Post by dBsooner
JustinS83 wrote:
dBsooner wrote:Thank you, Justin! Good stuff! Is the update content capable of being HTML encode?
Yes, you can pass html for the content. Just don't do anything to crazy and change the look of the window or I'll have to start sanitizing the css and that's no fun :)
Just want to pass in a UL with LIs. Basically take what I’m already doing and pass it to WazeWrap instead of my own alertbox. Gracias!
dBsooner
Map Editor - Level 5
Map Editor - Level 5
Posts: 767
Has thanked: 367 times
Been thanked: 631 times
Send a message
https://s.waze.tools/scrp.pnghttps://s.waze.tools/am.pnghttps://s.waze.tools/betc.pnghttps://s.waze.tools/beta.pnghttps://s.waze.tools/mapr.pnghttps://storage.googleapis.com/wazeopedia-files/7/74/Waze_signature_200k_plain.pnghttps://s.waze.tools/c5s.png
• AM: Eastern Oklahoma, DFW, Southern Florida
• Wiki: WME | Editing Manual | Best Practices | FAQ | Places
• T-Mobile | iPhone 14 Pro | iOS Latest | Waze Latest Beta

Post by dBsooner
JustinS83 wrote:
crazycaveman wrote:I haven't seen that problem (regarding page never finishing loading) with the new update dialog, editor loads fine whether an update log is shown or not. However, regarding the update log, if there are several scripts that update and produce a scroll bar, I am unable to scroll the list with the mouse (in Chrome and Firefox, have to click and drag the bar). Would it be possible to make the list scrollable with the mouse wheel?
I noticed the scroll wheel was not working when I was developing it but I don't see a reason for it to not work. I tried forcing it and still no-go. Not sure what is going on to be honest.
I see this behavior in other webpages. One of which is my companies MNS / RMM portal. If I click to see a systems profile (popup of a ton of info about a computer / server) it opens in a overlaying div. wheel doesn’t work to scroll. Have to use scroll bar. Also, page down / page up doesn’t work either, unless I click somewhere in the actual div first. I think this is a problem with Chrome and handling DIV layer scrolling.
dBsooner
Map Editor - Level 5
Map Editor - Level 5
Posts: 767
Has thanked: 367 times
Been thanked: 631 times
Send a message
https://s.waze.tools/scrp.pnghttps://s.waze.tools/am.pnghttps://s.waze.tools/betc.pnghttps://s.waze.tools/beta.pnghttps://s.waze.tools/mapr.pnghttps://storage.googleapis.com/wazeopedia-files/7/74/Waze_signature_200k_plain.pnghttps://s.waze.tools/c5s.png
• AM: Eastern Oklahoma, DFW, Southern Florida
• Wiki: WME | Editing Manual | Best Practices | FAQ | Places
• T-Mobile | iPhone 14 Pro | iOS Latest | Waze Latest Beta

Post by dBsooner
Found an interesting z-index issue tonight. I can't seem to get the z-index high enough to be on-top of the UR Panel, but going to 10000 instead of 1000 gets above the turn restriction arrows. I found this by going directly to a UR in the URL (while I left my disabled turns enabled).

EDIT: Yep and I see a bug with URC-E too. LOL.
2019_02_18_18_34_55_Waze_Map_Editor.png
(194.86 KiB) Downloaded 1080 times
dBsooner
Map Editor - Level 5
Map Editor - Level 5
Posts: 767
Has thanked: 367 times
Been thanked: 631 times
Send a message
https://s.waze.tools/scrp.pnghttps://s.waze.tools/am.pnghttps://s.waze.tools/betc.pnghttps://s.waze.tools/beta.pnghttps://s.waze.tools/mapr.pnghttps://storage.googleapis.com/wazeopedia-files/7/74/Waze_signature_200k_plain.pnghttps://s.waze.tools/c5s.png
• AM: Eastern Oklahoma, DFW, Southern Florida
• Wiki: WME | Editing Manual | Best Practices | FAQ | Places
• T-Mobile | iPhone 14 Pro | iOS Latest | Waze Latest Beta