WME Mapraid Ottawa Overlay

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

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği indirebilmeniz için ayrıca Tampermonkey gibi bir eklenti kurmanız gerekmektedir.

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name                WME Mapraid Ottawa Overlay
// @namespace           https://greatest.deepsurf.us/users/5252
// @description         Creates polygons for MapRaid groups in a WME "Mapraid Ottawa Groups" layer
// @include             https://www.waze.com/editor/*
// @include             https://www.waze.com/*/editor/*
// @include             https://editor-beta.waze.com/*
// @version             1.6
// @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);
        //console.log('MapRaid: ' + raid_mapLayer.features[i].attributes.number + ': ' + raidCenterCheck);
        if(raidCenterCheck === true){
        	var raidLocationLabel = 'Raid Group ' + raid_mapLayer.features[i].attributes.number + ' - ' + $('.WazeControlLocationInfo').text();
    		setTimeout(function(){$('.WazeControlLocationInfo').text(raidLocationLabel)},200);
        }
    }
}

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","__MapraidOttawa");
        
    var raid_mapLayer = new mro_OL.Layer.Vector("Mapraid Ottawa", {
        displayInLayerSwitcher: true,
        uniqueName: "__MapraidOttawa"
    });
        
    I18n.translations.en.layers.name["__MapraidOttawa"] = "Mapraid Ottawa";
    mro_Map.addLayer(raid_mapLayer);
    raid_mapLayer.setVisibility(true);
    

var VPURUpdateTeam = [{lon:'-74.3060303',lat:'45.8201864'},{lon:'-74.380188',lat:'45.2623219'},{lon:'-73.5081482',lat:'45.15686389999999'},{lon:'-72.8160095',lat:'45.6342064'},{lon:'-73.578186',lat:'46.1018043'},{lon:'-74.3060303',lat:'45.8201864'}];
AddRaidPolygon(raid_mapLayer, VPURUpdateTeam,"#B29189","PUR Update Team");

var VGroup1 = [{lon:'-75.8784485',lat:'45.80965760000001'},{lon:'-75.7012939',lat:'45.4846878'},{lon:'-75.619313',lat:'45.4887139'},{lon:'-75.37445070000001',lat:'45.77039680000001'},{lon:'-75.4953003',lat:'45.9014773'},{lon:'-75.8784485',lat:'45.80965760000001'}];
AddRaidPolygon(raid_mapLayer, VGroup1,"#009D57","Group 1");

var VGroup2 = [{lon:'-75.8784485',lat:'45.80965760000001'},{lon:'-76.3975525',lat:'45.690832799999995'},{lon:'-76.1833191',lat:'45.5164516'},{lon:'-76.1011421',lat:'45.5149147'},{lon:'-75.82142610000001',lat:'45.4495625'},{lon:'-75.7012939',lat:'45.4846878'},{lon:'-75.8784485',lat:'45.80965760000001'}];
AddRaidPolygon(raid_mapLayer, VGroup2,"#A61B4A","Group 2");

var VGroup3 = [{lon:'-75.82142610000001',lat:'45.4495625'},{lon:'-76.1011421',lat:'45.5149147'},{lon:'-76.1833191',lat:'45.5164516'},{lon:'-76.3975525',lat:'45.690832799999995'},{lon:'-76.5692139',lat:'45.4312262'},{lon:'-75.8451915',lat:'45.41932'},{lon:'-75.82142610000001',lat:'45.4495625'}];
AddRaidPolygon(raid_mapLayer, VGroup3,"#F4B400","Group 3");

var VGroup4 = [{lon:'-75.8448482',lat:'45.41968150000001'},{lon:'-76.5688706',lat:'45.43158759999999'},{lon:'-76.4686203',lat:'45.1833678'},{lon:'-75.85938010000001',lat:'45.3642174'},{lon:'-75.8448482',lat:'45.41968150000001'}];
AddRaidPolygon(raid_mapLayer, VGroup4,"#3F5BA9","Group 4");

var VGroup5 = [{lon:'-75.8590368',lat:'45.3639762'},{lon:'-76.46827700000001',lat:'45.1831258'},{lon:'-76.0878754',lat:'44.9678343'},{lon:'-75.8310317',lat:'45.3168086'},{lon:'-75.8590368',lat:'45.3639762'}];
AddRaidPolygon(raid_mapLayer, VGroup5,"#795046","Group 5");

var VGroup6 = [{lon:'-75.8317183',lat:'45.3175329'},{lon:'-76.088562',lat:'44.968563'},{lon:'-75.6394958',lat:'44.834326'},{lon:'-75.7571733',lat:'45.2778101'},{lon:'-75.8317183',lat:'45.3175329'}];
AddRaidPolygon(raid_mapLayer, VGroup6,"#62AF44","Group 6");

var VGroup7 = [{lon:'-75.757345',lat:'45.277689300000006'},{lon:'-75.6396675',lat:'44.8342043'},{lon:'-75.25377280000001',lat:'44.8478368'},{lon:'-75.6694073',lat:'45.2963304'},{lon:'-75.757345',lat:'45.277689300000006'}];
AddRaidPolygon(raid_mapLayer, VGroup7,"#A61B4A","Group 7");

var VGroup8 = [{lon:'-75.2541161',lat:'44.8478368'},{lon:'-74.9286461',lat:'44.97621379999999'},{lon:'-75.5762497',lat:'45.3302903'},{lon:'-75.6697506',lat:'45.2963304'},{lon:'-75.2541161',lat:'44.8478368'}];
AddRaidPolygon(raid_mapLayer, VGroup8,"#7C3592","Group 8");

var VGroup9 = [{lon:'-75.57573470000001',lat:'45.3295662'},{lon:'-74.9281311',lat:'44.9754852'},{lon:'-74.7605896',lat:'45.252655'},{lon:'-74.9995422',lat:'45.4976842'},{lon:'-75.5579189',lat:'45.3787895'},{lon:'-75.57573470000001',lat:'45.3295662'}];
AddRaidPolygon(raid_mapLayer, VGroup9,"#F8971B","Group 9");

var VGroup10 = [{lon:'-74.9995422',lat:'45.4976842'},{lon:'-75.37445070000001',lat:'45.77039680000001'},{lon:'-75.619313',lat:'45.4887139'},{lon:'-75.5742645',lat:'45.45483260000001'},{lon:'-75.5579189',lat:'45.3787895'},{lon:'-74.9995422',lat:'45.4976842'}];
AddRaidPolygon(raid_mapLayer, VGroup10,"#0BA9CC","Group 10");

var VGroup11 = [{lon:'-75.82142610000001',lat:'45.4505259'},{lon:'-75.8451915',lat:'45.42028390000001'},{lon:'-75.8597234',lat:'45.3648205'},{lon:'-75.8317183',lat:'45.3176536'},{lon:'-75.7571733',lat:'45.2779308'},{lon:'-75.6692356',lat:'45.2965719'},{lon:'-75.57573470000001',lat:'45.3305317'},{lon:'-75.5579189',lat:'45.3797541'},{lon:'-75.5742645',lat:'45.4557959'},{lon:'-75.619313',lat:'45.4896766'},{lon:'-75.7012939',lat:'45.48565060000001'},{lon:'-75.82142610000001',lat:'45.4505259'}];
AddRaidPolygon(raid_mapLayer, VGroup11,"#000000","Group 11");


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