WME NC Mapraid Overlay

Creates polygons for MapRaid groups in a WME "NC Mapraid Groups" layer

目前為 2016-06-01 提交的版本,檢視 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name                WME NC Mapraid Overlay
// @namespace           https://greasyfork.org/users/5252
// @description         Creates polygons for MapRaid groups in a WME "NC Mapraid Groups" layer
// @include             https://www.waze.com/editor/*
// @include             https://www.waze.com/*/editor/*
// @include             https://editor-beta.waze.com/*
// @version             2.3
// @grant               none
// @copyright           2014 davielde
// ==/UserScript==


//---------------------------------------------------------------------------------------


//generated by rickzabel's overlay generator

//RZ RaidName will be replaced by the name of the layer in your KML file
//RZ RaidNameNoSpaces will be replaced by the name of the layer in your KML file
//RZ AreaPoints will be replaced by the names, colors, and area points from your KML file

setTimeout(InitMapRaidOverlay, 1000);

function AddRaidPolygon(raidLayer,groupPoints,groupColor,groupNumber){
    
    var mro_Map = Waze.map;
    var mro_OL = OpenLayers;
    var raidGroupLabel = 'Raid Group ' + groupNumber;
    var groupName = 'RaidGroup' + groupNumber;
    
    var style = {
        strokeColor: groupColor,
        strokeOpacity: .8,
        strokeWidth: 3,
        fillColor: groupColor,
        fillOpacity: 0.15,
        label: raidGroupLabel,
        labelOutlineColor: "black",
        labelOutlineWidth: 3,
        fontSize: 14,
        fontColor: groupColor,
        fontOpacity: .85,
        fontWeight: "bold"  
    };
    
    var attributes = {
        name: groupName,
        number: groupNumber
    };
    
    var pnt= [];
    for(i=0;i<groupPoints.length;i++){
        convPoint = new OpenLayers.Geometry.Point(groupPoints[i].lon,groupPoints[i].lat).transform(new OpenLayers.Projection("EPSG:4326"), mro_Map.getProjectionObject());
        //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 CurrentRaidLocation(raid_mapLayer){
    var mro_Map = Waze.map;

    for(i=0;i<raid_mapLayer.features.length;i++){
        var raidMapCenter = mro_Map.getCenter();
        var raidCenterPoint = new OpenLayers.Geometry.Point(raidMapCenter.lon,raidMapCenter.lat);
        var raidCenterCheck = raid_mapLayer.features[i].geometry.components[0].containsPoint(raidCenterPoint);
		var holes = raid_mapLayer.features[i].attributes.holes
		
        
        if(raidCenterCheck === true){

			var str = $('#topbar-container > div > div.location-info-region > div').text();
			
			var n2 = str.indexOf(" - ");
			
			if(n2 > 0){
				var n = str.length;
				var res = str.substring(n2+2, n);
				var rescount = res.indexOf(" - ");
				if(rescount>0){
					var n3 = res.length;
					var res2 = res.substring(rescount+2, n3);
				}
				var raidLocationLabel = '[Raid Group - ' + raid_mapLayer.features[i].attributes.number + '] - ' + res2;

			} else {
				var raidLocationLabel = '[Raid Group - ' + raid_mapLayer.features[i].attributes.number + '] - ' + $('#topbar-container > div > div.location-info-region > div').text();
						
			}	
			setTimeout(function(){$('#topbar-container > div > div.location-info-region > div').text(raidLocationLabel);},200);
			 if (holes === "false") { break; }
		}
    }
}

function InitMapRaidOverlay(){

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

    //if (!mro_Map) return;
	
    //if (!mro_OL) return;

    var mro_mapLayers = mro_Map.getLayersBy("uniqueName","__NCMapraid");
        
    var raid_mapLayer = new mro_OL.Layer.Vector("NC Mapraid", {
        displayInLayerSwitcher: true,
        uniqueName: "__NCMapraid"
    });
        
    I18n.translations.en.layers.name["__NCMapraid"] = "NC Mapraid";
    mro_Map.addLayer(raid_mapLayer);
    raid_mapLayer.setVisibility(true);
    

var VGroup1 = [{lon:'-81.059443',lat:'35.150727'},{lon:'-81.057746',lat:'35.065674'},{lon:'-81.042125',lat:'35.043523'},{lon:'-80.934878',lat:'35.106269'},{lon:'-80.783243',lat:'34.934155'},{lon:'-80.798001',lat:'34.819592'},{lon:'-80.561969',lat:'34.81747'},{lon:'-80.027264',lat:'36.542498'},{lon:'-81.676827',lat:'36.59675'},{lon:'-81.978462',lat:'36.236953'},{lon:'-82.367441',lat:'36.122428'},{lon:'-82.51733',lat:'36.007336'},{lon:'-82.669942',lat:'36.123741'},{lon:'-83.027261',lat:'35.853236'},{lon:'-83.337334',lat:'35.674791'},{lon:'-83.492849',lat:'35.586006'},{lon:'-83.640883',lat:'35.587602'},{lon:'-83.874756',lat:'35.538777'},{lon:'-84.026033',lat:'35.429328'},{lon:'-84.053799',lat:'35.314633'},{lon:'-84.104812',lat:'35.258138'},{lon:'-84.224241',lat:'35.270471'},{lon:'-84.290599',lat:'35.226946'},{lon:'-84.322133',lat:'34.988508'},{lon:'-83.619899',lat:'34.985325'},{lon:'-83.026198',lat:'34.995119'},{lon:'-82.26198',lat:'35.198455'},{lon:'-81.059443',lat:'35.150727'}];
AddRaidPolygon(raid_mapLayer, VGroup1,"#F9F7A6","Group 1");

var VGroup2 = [{lon:'-78.546137',lat:'33.849692'},{lon:'-77.900403',lat:'36.545496'},{lon:'-80.027264',lat:'36.542498'},{lon:'-80.561969',lat:'34.81747'},{lon:'-79.6748988',lat:'34.80483'},{lon:'-78.546137',lat:'33.849692'}];
AddRaidPolygon(raid_mapLayer, VGroup2,"#DB4436","Group 2");

var VGroup3 = [{lon:'-77.882331',lat:'33.833427'},{lon:'-75.27102',lat:'35.206776'},{lon:'-75.665655',lat:'36.568631'},{lon:'-77.900403',lat:'36.545496'},{lon:'-78.546137',lat:'33.849692'},{lon:'-77.882331',lat:'33.833427'}];
AddRaidPolygon(raid_mapLayer, VGroup3,"#4186F0","Group 3");


    
	
	
    setTimeout(function(){CurrentRaidLocation(raid_mapLayer);},3000);
    mro_Map.events.register("moveend", Waze.map, function(){ setTimeout(function(){CurrentRaidLocation(raid_mapLayer);},1500);});
    mro_Map.events.register("zoomend", Waze.map, function(){ setTimeout(function(){CurrentRaidLocation(raid_mapLayer);},1500);});
       
       
}