WME TN Mapraid Overlay - Middle

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

// ==UserScript==
// @name                WME TN Mapraid Overlay - Middle
// @namespace           https://gf.qytechs.cn/users/5252
// @description         Creates polygons for MapRaid groups in a WME "TN Mapraid Groups" layer
// @include             https://www.waze.com/editor/*
// @include             https://www.waze.com/*/editor/*
// @include             https://editor-beta.waze.com/*
// @version             1.0
// @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: .2,
        strokeWidth: 2,
        fillColor: groupColor,
        fillOpacity: 0.5,
        label: raidGroupLabel,
        labelOutlineColor: "black",
        labelOutlineWidth: 0,
        fontSize: 14,
        fontColor: groupColor,
        fontOpacity: .5,
        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 str = $('#topbar-container > div > div.topbar > div.location-info-region > div.location-info').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();
				var raidLocationLabel = '[Raid Group - ' + raid_mapLayer.features[i].attributes.number + '] - ' + $('#topbar-container > div > div.topbar > div.location-info-region > div.location-info').text();		
			}	
			//setTimeout(function(){$('#topbar-container > div > div.location-info-region > div').text(raidLocationLabel);},200);
			setTimeout(function(){$('#topbar-container > div > div.topbar > div.location-info-region > div.location-info').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","__TNMapraid");
        
    var raid_mapLayer = new mro_OL.Layer.Vector("TN Mapraid (Middle)", {
        displayInLayerSwitcher: true,
        uniqueName: "__TNMapraid"
    });
        
    I18n.translations.en.layers.name["__TNMapraid"] = "TN Mapraid (Middle)";
    mro_Map.addLayer(raid_mapLayer);
    raid_mapLayer.setVisibility(true);
    

var VGroup1 = [{lon:'-89.50301',lat:'36.69573'},{lon:'-87.64459',lat:'36.67632'},{lon:'-87.38159',lat:'34.98191'},{lon:'-90.32177',lat:'34.98191'}];
AddRaidPolygon(raid_mapLayer, VGroup1,"black","West TN");

//var VGroup2 = [{lon:'-87.64459',lat:'36.67632'},{lon:'-85.78881',lat:'36.65693'},{lon:'-85.85540',lat:'34.98191'},{lon:'-87.38159',lat:'34.98191'}];
//AddRaidPolygon(raid_mapLayer, VGroup2,"black","Middle TN");

var VGroup3 = [{lon:'-85.78881',lat:'36.65693'},{lon:'-81.18078',lat:'36.60879'},{lon:'-84.31986',lat:'34.98191'},{lon:'-85.85540',lat:'34.98191'}];
AddRaidPolygon(raid_mapLayer, VGroup3,"black","East TN");

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址