- // ==UserScript==
- // @name WME Melbourne Australia Overlay
- // @namespace https://gf.qytechs.cn/users/5252
- // @description Creates polygons for MapRaid groups in a WME "Melbourne Australia 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 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 = 'County - ' + raid_mapLayer.features[i].attributes.number + ' - ' + res2;
-
- } else {
- //var raidLocationLabel = 'County - ' + raid_mapLayer.features[i].attributes.number + ' - ' + $('#topbar-container > div > div.location-info-region > div').text();
- var raidLocationLabel = 'County - ' + 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","__MelbourneAustralia");
-
- var raid_mapLayer = new mro_OL.Layer.Vector("Melbourne Australia", {
- displayInLayerSwitcher: true,
- uniqueName: "__MelbourneAustralia"
- });
-
- I18n.translations.en.layers.name["__MelbourneAustralia"] = "Melbourne Australia";
- mro_Map.addLayer(raid_mapLayer);
- raid_mapLayer.setVisibility(true);
-
-
- var VGroup1 = [{lon:'144.087969',lat:'-38.45902160000001'},{lon:'144.634443',lat:'-38.3176954'},{lon:'144.7950905',lat:'-38.1968961'},{lon:'144.684427',lat:'-38.0754777'},{lon:'144.6892995',lat:'-38.0076958'},{lon:'144.1831543',lat:'-38.0276586'},{lon:'144.087969',lat:'-38.45902160000001'}];
- AddRaidPolygon(raid_mapLayer, VGroup1,"#7C3592","Group 1");
-
- var VGroup2 = [{lon:'144.1831543',lat:'-38.0276586'},{lon:'144.6892995',lat:'-38.0076958'},{lon:'144.8029873',lat:'-37.92974'},{lon:'144.812209',lat:'-37.8929083'},{lon:'144.8427255',lat:'-37.5134365'},{lon:'144.3376918',lat:'-37.5581871'},{lon:'144.1831543',lat:'-38.0276586'}];
- AddRaidPolygon(raid_mapLayer, VGroup2,"#DB4436","Group 2");
-
- var VGroup3 = [{lon:'144.8427255',lat:'-37.5134365'},{lon:'144.812209',lat:'-37.8929083'},{lon:'144.9086417',lat:'-37.8943262'},{lon:'145.0346751',lat:'-38.00501980000001'},{lon:'145.0964749',lat:'-38.0288265'},{lon:'145.1005931',lat:'-37.9974447'},{lon:'145.088882',lat:'-37.51517270000001'},{lon:'144.8427255',lat:'-37.5134365'}];
- AddRaidPolygon(raid_mapLayer, VGroup3,"#7C3592","Group 3");
-
- var VGroup4 = [{lon:'145.088882',lat:'-37.51517270000001'},{lon:'145.1005931',lat:'-37.9974447'},{lon:'145.6457516',lat:'-37.72999600000001'},{lon:'145.39238',lat:'-37.5497493'},{lon:'145.088882',lat:'-37.51517270000001'}];
- AddRaidPolygon(raid_mapLayer, VGroup4,"#DB4436","Group 4");
-
- var VGroup5 = [{lon:'145.6938496',lat:'-38.0770229'},{lon:'145.6457516',lat:'-37.72999600000001'},{lon:'145.1005931',lat:'-37.9974447'},{lon:'145.09098',lat:'-38.0764032'},{lon:'145.0847116',lat:'-38.143926'},{lon:'145.4743071',lat:'-38.2850472'},{lon:'145.6938496',lat:'-38.0770229'}];
- AddRaidPolygon(raid_mapLayer, VGroup5,"#7C3592","Group 5");
-
- var VGroup6 = [{lon:'144.6518379',lat:'-38.309359099999995'},{lon:'144.89973720000003',lat:'-38.5475709'},{lon:'145.4374831',lat:'-38.5768044'},{lon:'145.4743071',lat:'-38.2850472'},{lon:'145.0847116',lat:'-38.143926'},{lon:'144.9570981',lat:'-38.2521889'},{lon:'144.7946782',lat:'-38.304867'},{lon:'144.6980981',lat:'-38.295963500000006'},{lon:'144.6518379',lat:'-38.309359099999995'}];
- AddRaidPolygon(raid_mapLayer, VGroup6,"#DB4436","Group 6");
-
-
-
- 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);});
-
- }