Open WME in GMM

Opens the current Waze Map Editor view in Google Map Maker

目前為 2015-12-03 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name 			Open WME in GMM
// @description 	Opens the current Waze Map Editor view in Google Map Maker
// @namespace 		vaindil
// @version 		0.6.3
// @grant           none
// @include         https://www.waze.com/editor/*
// @include         https://editor-beta.waze.com/*
// @author			vaindil
// ==/UserScript==

console.log("WMEGMM BEGINNING");

startcode = function() {
    try {
        var element = $('div .view-area.olMap #WazeMap');
        if (typeof element !== "undefined" && element.value !== '') {
            console.log("WMEGMM START");
            $('#sidepanel-prefs').append('<hr /><a id="WMEtoGMM" href="'+gen_url()+'" target="_blank" style="font-weight:bold;"><button class="btn">Open in GMM</button></a><hr />');
        } else {
            console.log("WMEGMM TIMEOUT");
            setTimeout(startcode, 1000);
        }
    } catch (err) {
        console.log("WME to GMM error: "+err);
        setTimeout(startcode, 1000);
    }
};

function gen_url() {
    var projI=new OpenLayers.Projection("EPSG:900913");
    var projE=new OpenLayers.Projection("EPSG:4326");
    var center_lonlat=(new OpenLayers.LonLat(Waze.map.center.lon,Waze.map.center.lat)).transform(projI, projE);
    var topleft=(new OpenLayers.LonLat(Waze.map.getExtent().left,Waze.map.getExtent().top)).transform(projI, projE);
    var bottomright=(new OpenLayers.LonLat(Waze.map.getExtent().right,Waze.map.getExtent().bottom)).transform(projI, projE);
    lat=Math.round(center_lonlat.lat * 1000000)/1000000;
    lon=Math.round(center_lonlat.lon * 1000000)/1000000;
    spn=Math.abs(topleft.lat-bottomright.lat)+','+Math.abs(topleft.lon-bottomright.lon);
    return 'https://www.google.com/mapmaker?ll='+lat+','+lon+'&spn='+spn+'&lyt=large_map_v3';
}

$('#editor-container').mouseup(function() {
    $('#WMEtoGMM').attr('href', gen_url());
});

startcode();