Greasy Fork

Greasy Fork is available in English.

Open WME in EST

Opens the current Waze Map Editor view in Estonian Land Board Geoportal

当前为 2021-09-03 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Open WME in EST
// @description     Opens the current Waze Map Editor view in Estonian Land Board Geoportal
// @version         0.9
// @include         /^https:\/\/(www|beta)\.waze\.com\/*\/(?!user\/)(.{2,6}\/)?editor.*$/
// @include         https://xgis.maaamet.ee/maps/*
// @include         https://xgis.maaamet.ee/xgis2/page/app/*
// @require         http://greasyfork.icu/scripts/383120-proj4-wazedev/code/proj4-Wazedev.js
// @author          script is based from orignal google maps script, modified by rain101
// @namespace       http://greasyfork.icu/users/207621
// ==/UserScript==

/* global $ */
/* global OpenLayers */
/* global I18n */
/* global W */
/* global proj4 */

console.log("WME_EE BEGINNING");

var icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAArUlEQVQokbXMPQ6CMBxA8X80EMpgcdBRowaMB2NquKKLxEQ08WOCiR4BptLpeYjqS37rk5OpyU1Dbm7BjuaK5ObGzrzYmWegF7lpkKK6s68+7Kt3oA9F9UAO5ZlNWbMtL4FqDuUZUYs1syRjrpZBZklGslghcRwjIj8RRdEfhlprlFKkaRpEKYXWGmnbFmstfd8HsdbSdR3inONXOef+MByGAe890zQF8d4zjiNfdeREmfFbjlgAAAAASUVORK5CYII=';

function gen_url() {

  var geoPoint=new OpenLayers.Geometry.Point(W.map.getCenter().lon,W.map.getCenter().lat);
  proj4.defs("EPSG:3301", "+proj=lcc +lat_1=59.33333333333334 +lat_2=58 +lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs");

  var source = new proj4.Proj("EPSG:900913");
  var dest = new proj4.Proj("EPSG:3301");

  geoPoint = proj4.transform(source, dest, geoPoint);

  var zoom = W.map.getZoom() - 12; // Waze zoom levels start from 12 to 22 now
  var array = [61440, 30720, 15360, 7680, 3840, 1920, 960, 480, 240, 120, 60];

  // Normal Flash Estonian Landboard page
  // return 'http://xgis.maaamet.ee/xGIS/XGis?app_id=UU82&user_id=at&punkt=' + point.x + ',' + point.y + '&moot=4000';

  // HTML5 Estonian Landboard page
  //return 'http://xgis.maaamet.ee/maps/XGis?app_id=UU82A&user_id=at&zlevel=' + zoom + ',' + point.x + ',' + point.y;

  //https://xgis.maaamet.ee/xgis2/page/app/maainfo?punkt=542228.98,6588663.63&moot=2000
  //https://xgis.maaamet.ee/xgis2/page/app/maainfo?punkt=6580101.69,549967.00&moot=100
  return 'https://xgis.maaamet.ee/xgis2/page/app/maainfo?punkt=' + geoPoint.x + ',' + geoPoint.y + '&moot=' + array[zoom];
}

function init() {
  try {
      //var element = $('.WazeControlPermalink');
      var insertPath = '.WazeControlPermalink';
      if ($(insertPath).length) {
          let $section = $("<div>", {style:"padding:8px 16px"});
          $section.html([
              '<span id="WMEtoEE">',
              `<img src="${icon}" alt="EE" id="WMEtoEEImg" title="Open in Estoninan Landboard" style="cursor:pointer; float: left; display:inline-block; margin: 2px 5px 0 3px;">`,
              '</span>',
          ].join(' '));

          $(insertPath).prepend($section.html());

          $('#WMEtoEEImg').click(function(){
              window.open(gen_url(), '_blank');
          });

          console.log("WME_EE done");
        } else {
          setTimeout(init, 1000);
        }
  } catch (err) {
    console.log("WME_EE - " + err);
    setTimeout(init, 1000);
  }
}

init();