Skip to content

Commit

Permalink
Update OpenOtherMaps.js
Browse files Browse the repository at this point in the history
Adding bidirectional support for Roadworks
  • Loading branch information
justins83 authored Jul 30, 2018
1 parent 89e8f30 commit e1d12a3
Showing 1 changed file with 74 additions and 8 deletions.
82 changes: 74 additions & 8 deletions OpenOtherMaps.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ==UserScript==
// @name WME Open Other Maps
// @namespace https://greasyfork.org/users/30701-justins83-waze
// @version 2018.07.26.01
// @version 2018.07.30.01
// @description Links for opening external resources at the WME location and WME from external resources
// @author JustinS83
// @include https://www.waze.com/editor*
Expand All @@ -20,6 +20,7 @@
// @include http://nmroads.com/mapIndex.html*
// @include https://gis.transportation.wv.gov/measures*
// @include https://www.mapwv.gov/flood/map*
// @include https://roadworks.org/*
// @exclude https://www.waze.com/*/user/editor*
// @require https://greasyfork.org/scripts/24851-wazewrap/code/WazeWrap.js
// @require https://greasyfork.org/scripts/13097-proj4js/code/Proj4js.js
Expand Down Expand Up @@ -47,6 +48,7 @@
var PA511Icon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAACClBMVEX//vz//vv8+/r4+Pj7+vn9/Pr///709vfn6u7U2+Td4ei/ydmotc/r7fBziLHHz92+x9qsuc/y9Pf////29/fX2+b9/f7+/v79/v18j7Q9WZPO1eH//v7n6u3+///AydpbcaG5xNfO1eS2wdiyvtavu9TFzt7m6e6/x9j///3p7fDDzdu+yNkML3kaPIDk6PD5+fktSokWOYBMZpxBXZeDlLbd4us6V5EkRYTY3uhFYJUYPH/7/PtziLMzUpKRo8Pi5u0QNYA1VJOTo8Wgrsjv8/aRpMEAH25je6mltc0CKXU4V5O4w9Zddqdrgq3R1uQaPIE8WpROap8AJXJofqzGzt0AJnOFmb73+foWO4BIZJnd4u1Rap9cdKb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RxPjHoxPJkYTE2OicvEy0Omi0eT3dHN+59xz7rmI1sXp3LyW5LXujM6VQd0cSnL6XkFP1THQ2QZGWsRo4SdNDe3lUZJHXRm9mzOQvIEWrX6pLSzjXtlURyL8sonJmb0ShGByiI7k6g5M6cnhjGRiZMKbt7Ly3Ky8W+I7orIjlC/enpq8VRCmblgY0XIsIzAaa6ZsYgvKCw8EsGMFW9jB6khgNPflRT/YsR2uTZjotMUrQhDoNGjcxxHMP5nnwLYFKCpItWJ4Xer7WiFqivpwOWZwjRB+iQjkm1q9jg86culRurptrimqmnK2yaa6jqI+WB7QdV8ifDlzQG5oEuzKGcw9e5wC22ZY5MQ5QX2wFNG0x7E+3sSICErxeoq3s+L64jiowDqnon+wqXq7TncGhzCKM1I8Ah1nUCwvjVYrpuOIP5aC2llQ1r/ZiFODPEbzCO4RpmduvlM8f7nbb3za6rw3W3R4U4gBbgOZXrk/DMr/1FSvnobOOFm0O4kYaNgbt/pwBJThuE7FnUJ1tBZWn49gvRNQg4vHl+YuV5X/0SIt7VGcSiPGPhHz5ErzY0BpgeP6dSSgTuOkgRpqmo4BjE4h0IGPtrJY/LgbAHvnQFlXd8oasGP/vEdV97trW3jDARX8aGNc2zVI+HioiTgjtrE84YolM8nNheS3lwPPV4eLkwk7GWFiQzPTo+/3Yh/243fvJMlQVN+TIHwCQvgkSyBvYSWzTzB7OZwaM3bF0M640Z0gPFesfp7wpIyuYbQjrLkQRXsSJk/a7BcQW7BgZfO2YN4eKthDV+E3sbEixBmSW/uvtYavt4YLjouy1Z+1BrIWVjQHsoRf+A79jNM0D/QKqgAAAABJRU5ErkJggg==";
Expand Down Expand Up @@ -83,6 +85,7 @@
`<div><input type="checkbox" id="chkYandex" class="OOMchk"><label for="chkYandex"><img src="${yandexIcon}" height="18" width ="18">Yandex</label></div>`,
`<div><input type="checkbox" id="chkHere" class="OOMchk"><label for="chkHere"><img src="${hereIcon}" height="18" width ="18">Here</label></div>`,
`<div><input type="checkbox" id="chkZoomEarth" class="OOMchk"><label for="chkZoomEarth"><img src="${ZoomEarthIcon}" height="18" width ="18">Zoom Earth</label></div>`,
`<div title='Roadworks (https://roadworks.org/)'><input type="checkbox" id="chkRoadworks" class="OOMchk"><label for="chkRoadworks"><img src="${RoadworksIcon}" height="18" width ="18">Roadworks</label></div>`,
'</br><div>',
'<fieldsetstyle="border: 1px solid silver; padding: 8px; border-radius: 4px;">',
'<legend style="margin-bottom:0px; border-bottom-style:none;width:auto;"><h4>Map Language (where applicable)</h4></legend>',
Expand Down Expand Up @@ -123,6 +126,7 @@
setChecked('chkGMDM', settings.GMDM);
setChecked('chkBogota', settings.Bogota);
setChecked('chkZoomEarth', settings.ZoomEarth);
setChecked('chkRoadworks', settings.Roadworks);

if(settings.LangSetting == 0)
setChecked("radOOMNoLang", true);
Expand Down Expand Up @@ -623,6 +627,24 @@
window.open(`https://zoom.earth/#${latlon.lat},${latlon.lon},${( W.map.zoom + 12)}z,map`, 'Zoom Earth');
});
}

$('#OOMRoadworks').remove();
if(settings.Roadworks)
{
let $section = $("<div>", {style:"padding:8px 16px"});
$section.html([
'<span id="OOMRoadworks">',
`<img src="${RoadworksIcon}" alt="Roadworks" width="18" height="18" id="OOMRoadworksImg" title="Open in Roadworks" style="cursor:pointer; float: left; display:inline-block; margin: 2px 5px 0 3px;">`,
'</span>'
].join(' '));

$('.view-area.olMap >div > div > div.WazeControlPermalink').append($section.html());

$('#OOMRoadworksImg').click(function(){
let latlon = get4326CenterPoint();
window.open(`https://roadworks.org/?lng=${latlon.lon}&lat=${latlon.lat}&zoom=${( W.map.zoom + 12)}`, 'Roadworks');
});
}
}

function loadSettings() {
Expand All @@ -649,7 +671,8 @@
GMDM: false,
PennDOT: false,
Bogota: false,
ZoomEarth: false
ZoomEarth: false,
Roadworks: false
//NJ511: false
};
settings = loadedSettings ? loadedSettings : defaultSettings;
Expand Down Expand Up @@ -683,7 +706,8 @@
GMDM: settings.GMDM,
PennDOT: settings.PennDOT,
Bogota: settings.Bogota,
ZoomEarth: settings.ZoomEarth
ZoomEarth: settings.ZoomEarth,
Roadworks: settings.Roadworks
//NJ511: settings.NJ511
};

Expand Down Expand Up @@ -730,12 +754,17 @@
}

function bootstrapNM511(tries = 1){
if(map && map.extent && map.loaded){
if(map && map.extent && map.loaded)
initNM511();
}
else{
else
setTimeout(function() {bootstrapNM511(tries++);}, 100);
}
}

function bootstrapRoadworks(tries = 1){
if(Elgin && Elgin.map && Elgin.map.tilesloading === false)
initRoadworks();
else
setTimeout(function(){bootstrapRoadworks(tries++);}, 100);
}

function bootstrap(tries = 1) {
Expand Down Expand Up @@ -768,6 +797,9 @@
else if(location.href.indexOf("https://www.mapwv.gov/flood/map") > -1){
bootstrapGeneral(initWVFlood, 1);
}
else if(location.href.indexOf("https://roadworks.org/") > -1){
bootstrapRoadworks(1);
}
/*else if(location.href.indexOf("http://www.511nj.org/trafficmap") > -1){
bootstrapGeneral(initNJ511, 1);
}*/
Expand Down Expand Up @@ -892,7 +924,7 @@

let $OOMWazeButton = document.createElement("li");

$OOMWazeButton.innerHTML = '<span id="OOMWazeButton" style="background-image: url(https://imgur.com/NTLWfFz.png;"></span>';
$OOMWazeButton.innerHTML = '<span id="OOMWazeButton" style="background-image: url(https://imgur.com/NTLWfFz.png);"></span>';
document.getElementsByClassName('mapSettingsList')[0].appendChild($OOMWazeButton);

document.getElementById("OOMWazeButton").addEventListener("click", function(){
Expand Down Expand Up @@ -929,6 +961,40 @@
insertWMELinkNM511();
}

function insertWMELinkRoadworks(){
if(document.getElementById("OOMWazeButton") !== null)
document.getElementById("OOMWazeButton").remove();

let $OOMWazeButton = document.createElement("li");
$OOMWazeButton.style.minHeight = "60px";
$OOMWazeButton.id = "OOMWazeButton";
$OOMWazeButton.innerHTML = '<a href="#"><span style="background-image: url(https://imgur.com/NTLWfFz.png); background-repeat:no-repeat; background-position:center;"></span></a>';
document.getElementById('nav-main').getElementsByTagName('ul')[0].appendChild($OOMWazeButton);

document.getElementById("OOMWazeButton").addEventListener("click", function(){
let source = new Proj4js.Proj('EPSG:900913');
let center = Elgin.map.getCenter();
window.open(`https://www.waze.com/en-US/editor/?lon=${center.lng()}&lat=${center.lat()}&zoom=${(Math.max(0,Math.min(10,(Elgin.map.zoom - 12))))}`);
});
}

function initRoadworks(){
if(location.search.indexOf("?") > -1){
let params = location.search.match(/lng=(-?\d*.\d*)&lat=(-?\d*.\d*)&zoom=(\d+)/);
debugger;
setTimeout(function(){
try{
Elgin.map.setCenter({lng:parseFloat(params[1]), lat:parseFloat(params[2])});
setTimeout(function(){Elgin.map.setZoom(parseInt(params[3]));}, 500);
}
catch(err) {
console.log(err);
}
}, 1000);
}
insertWMELinkRoadworks();
}

var copyToClipboard = function(str) {
var temp = document.createElement("input");
document.body.append(temp);
Expand Down

0 comments on commit e1d12a3

Please sign in to comment.