Numerous changes to WME since the production push yesterday/today broke this script. I have reached out to the author but he hasn't been in the forum since July, so outlined below are the changes that I made to fix the script.
To get it to work in the beta editor change
to
To fix the script since WME update yesterday:
Change all instances of:
to
Change the removeDragCallbacks function to this (starts at roughly line 112 and goes to 123):
Some things need changed & moved around in the checkSelection function, so I will just paste the changes here. Copy and paste over the entire function (starts around line 194 and ends at roughly 238)
To get it to work in the beta editor change
Code: Select all
// @include https://editor-beta.waze.com/*
Code: Select all
// @include https://beta.waze.com/*
Change all instances of:
Code: Select all
W.geometryEditing.editors.venue
Code: Select all
W.geometryEditing.activeEditor
Change the removeDragCallbacks function to this (starts at roughly line 112 and goes to 123):
Code: Select all
function removeDragCallbacks() {
if(!W.geometryEditing.activeEditor == null){
W.geometryEditing.activeEditor.dragControl.onDrag = function (e, t) {
W.geometryEditing.activeEditor.dragVertex.apply(W.geometryEditing.activeEditor.venue, [e, t]);
};
if (null !== typeof navPoint) {
try {
navPoint.events.unregister('drag', W.geometryEditing.activeEditor.venue, findNearestSegment);
} catch (err) { }
}
}
clearLayerFeatures();
}
Code: Select all
function checkSelection() {
'use strict';
log('Selection change called.', 2);
if (!checkConditions()) {
removeDragCallbacks();
} else {
if (W.selectionManager.hasSelectedItems()) {
selectedItem = W.selectionManager.selectedItems[0];
if ('venue' !== selectedItem.model.type) {
log('Selection is not a place.', 2);
removeDragCallbacks();
clearLayerFeatures();
} else {
navPoint = W.geometryEditing.activeEditor.navigationPoint;
getSegmentsInExtent();
if (selectedItem.model.isPoint()) {
log('Selection is point venue.', 2);
W.geometryEditing.activeEditor.dragControl.onDrag = function (e, t) {
W.geometryEditing.activeEditor.venue.dragVertex.apply(W.geometryEditing.activeEditor.venue, [e, t]);
findNearestSegment();
};
findNearestSegment();
} else {
log('Selection is area venue.', 2);
if (null !== typeof navPoint) {
navPoint.events.register('drag', W.geometryEditing.activeEditor.venue, findNearestSegment);
if (inMapExtent(navPoint.lonlat.toPoint())) {
findNearestSegment();
} else {
log('navPoint not on screen.', 2);
W.map.events.register('moveend', window, handleNavPointOffScreen);
}
}
}
}
} else {
log('No item selected.', 2);
removeDragCallbacks();
clearLayerFeatures();
}
}
}
Re: [Script] WME Closest Segment