WME GIS Locator

opens associated county GIS map and takes you to the latitude and longitude you were at (in WME) on the GIS map just opened.

当前为 2018-03-07 提交的版本,查看 最新版本

// ==UserScript==
// @name         WME GIS Locator
// @namespace    http://tampermonkey.net/
// @version      2018.03.05.01
// @description  opens associated county GIS map and takes you to the latitude and longitude you were at (in WME) on the GIS map just opened.
// @author       ramblinwreck_81
// @include      https://www.waze.com/editor*
// @exclude      https://www.waze.com/user/editor*
// @grant        none
//@locale English


// This script requires WME GIS Buttons script installed


// ==/UserScript==

(function() {
    'use strict';

    function bootstrap(tries) {
        tries = tries || 1;

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

//init();
    function WMEGLinit() {
        setTimeout(init,8000);
    }
    function init()
    {
  //    alert("running");
        addLocateButton();
  function addLocateButton () {
  //    alert ("adding locate button");
    var WMEGLy = document.createElement('div');
    WMEGLy.setAttribute('id', 'lat-long-info');
    WMEGLy.setAttribute('style', 'display:inline;');
    document.getElementById('Wazebar').appendChild(WMEGLy);
    var WMEGLbb = document.createElement('button');
    WMEGLbb.setAttribute('type', 'button');
    WMEGLbb.setAttribute('value', 'Submit');
    WMEGLbb.setAttribute('id', 'WME-GIS-locator');
    WMEGLbb.setAttribute('title', 'initiate WME GIS Locator script');
    WMEGLbb.innerHTML = 'Locate';
    document.getElementById('lat-long-info').appendChild(WMEGLbb);
    document.getElementById("WME-GIS-locator").style.height="20px";
    document.getElementById("WME-GIS-locator").style.width="50px";
    document.getElementById('WME-GIS-locator').style.padding='1px';
    document.getElementById('WME-GIS-locator').disabled = false;
  }  // end of addLocateButton function
  document.getElementById("WME-GIS-locator").addEventListener("click",localize, false);

  function localize() {
      var WMEGLpoint = document.getElementsByClassName("mouse-position")[0].innerHTML;
      var WMEGLarr= WMEGLpoint.split(" ");
      var WMEGLlong = WMEGLarr[0];
      var WMEGLlat = WMEGLarr[1];
      var WMEGLletsGo = false;
      var WMEGLlatTimer;
      var WMEGLgetLat = false;
    var WMEGLurl = 'https://www.waze.com/en-US/editor/?env=usa&lon=' + WMEGLarr[0] + '&lat=' + WMEGLarr[1] + '&zoom=4';
    document.getElementById('county_gis').click();
    window.open(WMEGLurl,'wmeDup');
    WMEGLcreateElements();
    function WMEGLthisTimeLat() {
      clearInterval(WMEGLlatTimer);
      document.getElementById('WME-GIS-locator').disabled = false;
      document.getElementById("grab-long-lat").removeEventListener('click',coordinates, false);
      var removeElement = document.getElementById("grab-long-lat");
      removeElement.parentNode.removeChild(removeElement);
      removeElement = document.getElementById('long-and-lat-txt');
      removeElement.parentNode.removeChild(removeElement);
    } // end of WMEGLthisTimeLat function
  function WMEGLcreateElements() {
    // var WMEGLy=document.createElement("div");
    // WMEGLy.setAttribute("id", "lat-long-info");
    // document.getElementById("edit-buttons").appendChild(WMEGLy);
    var WMEGLz=document.createElement("button");
    WMEGLz.setAttribute("type", "button");
    WMEGLz.setAttribute("value", "Submit");
    WMEGLz.setAttribute("id","grab-long-lat");
    WMEGLz.setAttribute("title","Get Long");
    WMEGLz.innerHTML = "Get Longitude";
    var WMEGLaa=document.createElement('textArea');
    WMEGLaa.setAttribute("id", "long-and-lat-txt");
    WMEGLaa.textContent = "";
    document.getElementById("lat-long-info").appendChild(WMEGLaa);
    //document.getElementById('lat-and-long-txt').rows = '1';
    //document.getElementById('lat-and-long-txt').cols = '5';
    document.getElementById("lat-long-info").appendChild(WMEGLz);
    document.getElementById("grab-long-lat").style.height="20px";
    document.getElementById("grab-long-lat").style.width="100px";

  } // end of WMGGLcreateElements function
  function coordinates() {
    document.getElementById('WME-GIS-locator').disabled = true;
    if(WMEGLgetLat !==true) {
      document.getElementById("long-and-lat-txt").textContent = WMEGLarr[0];
      document.getElementById("long-and-lat-txt").select();
      document.execCommand("copy");
      var WMEGLa = document.getElementById("grab-long-lat");
      WMEGLa.innerHTML = "Get Latitude";
      WMEGLgetLat = true;
    } else {
      document.getElementById("long-and-lat-txt").textContent = WMEGLarr[1];
      document.getElementById("long-and-lat-txt").select();
      document.execCommand("copy");
      WMEGLlatTimer = setInterval(function(){WMEGLthisTimeLat();},10000);
    }
  }  //end of coordinates function
  document.getElementById("grab-long-lat").addEventListener("click",coordinates, false);
}  // end of localize function

    }  // end of init function

    bootstrap();
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址