Greasy Fork

Greasy Fork is available in English.

Open WME in EST NEW

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

当前为 2020-10-03 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name            Open WME in EST NEW
// @description     Opens the current Waze Map Editor view in Estonian Land Board Geoportal
// @version         0.6
// @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 */
/* eslint curly: ["warn", "multi-or-nest"]*/

console.log("WME_EE BEGINNING");

const 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);

  // waze zoom leveles 0-10
  const zoom = W.map.getZoom();

  var array = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0];
  // If Waze zoom is 0, then we'll take first array element and the result is:
  // Pow(2, 10]) * 175 = 179200
  // the result is opened map at level 1:179200 (landportal has 178985)

  var result = Math.pow(2, array[zoom]) * 175;

  // 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
  return 'https://xgis.maaamet.ee/xgis2/page/app/maainfo?punkt=' + geoPoint.x + ',' + geoPoint.y + '&moot=' + result;
}

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

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

          $('#WMEtoEE').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();