WME BeenHere

trash

Pada tanggal 14 Agustus 2015. Lihat %(latest_version_link).

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name                WME BeenHere
// @namespace           https://greasyfork.org/en/users/5920-rickzabel
// @description         trash
// @include             https://www.waze.com/editor/*
// @include             https://www.waze.com/*/editor/*
// @include             https://editor-beta.waze.com/*
// @version             0.0.4
// @grant               none
// ==/UserScript==
//---------------------------------------------------------------------------------------
function bootstrap_MapRaidOverlay() {
    var bGreasemonkeyServiceDefined = false;

    try {
        bGreasemonkeyServiceDefined = (typeof Components.interfaces.gmIGreasemonkeyService === "object");
    } catch (err) { /* Ignore */ }

    if (typeof unsafeWindow === "undefined" || !bGreasemonkeyServiceDefined) {
        unsafeWindow = (function() {
            var dummyElem = document.createElement('p');
            dummyElem.setAttribute('onclick', 'return window;');
            return dummyElem.onclick();
        })();
    }

    /* begin running the code! */
    setTimeout(InitMapRaidOverlay, 1000);

}

function AddRaidPolygon(raidLayer, groupPoints, groupColor, groupNumber) {


    var groupNumber = "me";
    var point = Waze.map.getExtent();
    var groupColor = 'orange';

    var groupPoints = [{
        lon: point.left,
        lat: point.top
    }, {
        lon: point.left,
        lat: point.bottom
    }, {
        lon: point.right,
        lat: point.bottom
    }, {
        lon: point.right,
        lat: point.top
    }, {
        lon: point.left,
        lat: point.top
    }];

    var mro_Map = unsafeWindow.Waze.map;
    var mro_OL = unsafeWindow.OpenLayers;
    var raidGroupLabel = "";
    var groupName = "";

    var style = {
        strokeColor: "orange",
        strokeOpacity: .8,
        strokeWidth: 8,
        fillColor: groupColor,
        fillOpacity: 0.0,
        label: raidGroupLabel,
        labelOutlineColor: "black",
        labelOutlineWidth: 3,
        fontSize: 14,
        fontColor: groupColor,
        fontOpacity: .85,
        fontWeight: "bold"
    };
    var attributes = {
        name: groupName
    };

    var pnt = [];
    for (i = 0; i < groupPoints.length; i++) {
        convPoint = new OpenLayers.Geometry.Point(groupPoints[i].lon, groupPoints[i].lat);
        //console.log('MapRaid: ' + JSON.stringify(groupPoints[i]) + ', ' + groupPoints[i].lon + ', ' + groupPoints[i].lat);
        pnt.push(convPoint);
    }

    var ring = new mro_OL.Geometry.LinearRing(pnt);
    var polygon = new mro_OL.Geometry.Polygon([ring]);
    var feature = new mro_OL.Feature.Vector(polygon, attributes, style);
    raidLayer.addFeatures([feature]);

}


function NewBox(mapLayers) {
    return function() {
        AddRaidPolygon(mapLayers);
    }
}

function RemoveLastBox(mapLayers) {
    return function() {
        //alert("RemoveLastBox");

        var mro_Map = unsafeWindow.Waze.map;
        var mro_mapLayers = mro_Map.getLayersBy("uniqueName", "__BeenHere");

        var mro_mapLayers_mapLayerLength = mro_mapLayers[0].features.length;
        if (mro_mapLayers_mapLayerLength > 0) {
            mro_mapLayers[0].features[mro_mapLayers_mapLayerLength - 1].destroy();
        }

    }
}


function RemoveAllBoxes(mapLayers) {
    return function() {
        //alert("RemoveLastBox");

        var mro_Map = unsafeWindow.Waze.map;
        var mro_mapLayers = mro_Map.getLayersBy("uniqueName", "__BeenHere");

        var mro_mapLayers_mapLayerLength = mro_mapLayers[0].features.length;
        if (mro_mapLayers_mapLayerLength > 0) {
            mro_mapLayers[0].destroyFeatures();
        }

    }
}


function InitMapRaidOverlay() {


    unsafeWindow.mapLayers = new unsafeWindow.OpenLayers.Layer.Vector("Been Here", {
        displayInLayerSwitcher: true,
        uniqueName: "__BeenHere"
    });

    unsafeWindow.Waze.map.addLayer(unsafeWindow.mapLayers);
    unsafeWindow.mapLayers.setVisibility(true);

    var mro_Map = unsafeWindow.Waze.map;
    var mro_OL = unsafeWindow.OpenLayers;

    if (mro_Map == null) return;
    if (mro_OL == null) return;

    //append our css to the head
    var g = '#RemoveLastBox {width: 40px; height: 40px; background: url("https://www.waze.com/assets-editor/images/toolbar-sb40be77eac.png") 0px -255px; zoom: .8;}';
    g = g + ' #NewBox {width: 40px; height: 40px; background: url("https://www.waze.com/assets-editor/images/toolbar-sb40be77eac.png") 0px -90px; zoom: .8;}'
	g = g + ' #TrashBox {width: 40px; height: 40px; background: url("https://www.waze.com/assets-editor/images/toolbar-sb40be77eac.png") 0px -217px; zoom: .8;}'
   
	g = g + '#panel-container .panel { left: 0px !important; top: 60px !important; bottom: 25px !important; margin-bottom: 15px !important;}';
	
    $("head").append($('<style type="text/css">' + g + '</style>'));

    //add controls to the map
    var c = '<div id="BeenHere" style="position: absolute; top:250px; left: 6px; z-index: 1040 !important; border-radius: 5px; padding: 4px;     background-color: #000000;);"><img id="NewBox" title="Draw a box around the visible area"><br><img id="RemoveLastBox" title="Remove last box"><br><img id="TrashBox" title="Remove all boxes"></div>';
    $("#WazeMap").append(c);

    //set up listeners 
    $("#NewBox").click(NewBox(mapLayers));
    $("#RemoveLastBox").click(RemoveLastBox(mapLayers));
	$("#TrashBox").click(RemoveAllBoxes(mapLayers));

}

bootstrap_MapRaidOverlay();