WME TN Mapraid Overlay - Middle

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

  1. // ==UserScript==
  2. // @name WME TN Mapraid Overlay - Middle
  3. // @namespace https://gf.qytechs.cn/users/5252
  4. // @description Creates polygons for MapRaid groups in a WME "TN Mapraid Groups" layer
  5. // @include https://www.waze.com/editor/*
  6. // @include https://www.waze.com/*/editor/*
  7. // @include https://editor-beta.waze.com/*
  8. // @version 1.0
  9. // @grant none
  10. // @copyright 2014 davielde
  11. // ==/UserScript==
  12.  
  13.  
  14. //---------------------------------------------------------------------------------------
  15.  
  16.  
  17. //generated by rickzabel's overlay generator
  18.  
  19. //RZ RaidName will be replaced by the name of the layer in your KML file
  20. //RZ RaidNameNoSpaces will be replaced by the name of the layer in your KML file
  21. //RZ AreaPoints will be replaced by the names, colors, and area points from your KML file
  22.  
  23. setTimeout(InitMapRaidOverlay, 1000);
  24.  
  25. function AddRaidPolygon(raidLayer,groupPoints,groupColor,groupNumber){
  26. var mro_Map = Waze.map;
  27. var mro_OL = OpenLayers;
  28. var raidGroupLabel = 'Raid Group ' + groupNumber;
  29. var groupName = 'RaidGroup' + groupNumber;
  30. var style = {
  31. strokeColor: groupColor,
  32. strokeOpacity: .2,
  33. strokeWidth: 2,
  34. fillColor: groupColor,
  35. fillOpacity: 0.5,
  36. label: raidGroupLabel,
  37. labelOutlineColor: "black",
  38. labelOutlineWidth: 0,
  39. fontSize: 14,
  40. fontColor: groupColor,
  41. fontOpacity: .5,
  42. fontWeight: "bold"
  43. };
  44. var attributes = {
  45. name: groupName,
  46. number: groupNumber
  47. };
  48. var pnt= [];
  49. for(i=0;i<groupPoints.length;i++){
  50. convPoint = new OpenLayers.Geometry.Point(groupPoints[i].lon,groupPoints[i].lat).transform(new OpenLayers.Projection("EPSG:4326"), mro_Map.getProjectionObject());
  51. //console.log('MapRaid: ' + JSON.stringify(groupPoints[i]) + ', ' + groupPoints[i].lon + ', ' + groupPoints[i].lat);
  52. pnt.push(convPoint);
  53. }
  54. var ring = new mro_OL.Geometry.LinearRing(pnt);
  55. var polygon = new mro_OL.Geometry.Polygon([ring]);
  56. var feature = new mro_OL.Feature.Vector(polygon,attributes,style);
  57. raidLayer.addFeatures([feature]);
  58.  
  59. }
  60.  
  61. function CurrentRaidLocation(raid_mapLayer){
  62. var mro_Map = Waze.map;
  63.  
  64. for(i=0;i<raid_mapLayer.features.length;i++){
  65. var raidMapCenter = mro_Map.getCenter();
  66. var raidCenterPoint = new OpenLayers.Geometry.Point(raidMapCenter.lon,raidMapCenter.lat);
  67. var raidCenterCheck = raid_mapLayer.features[i].geometry.components[0].containsPoint(raidCenterPoint);
  68. var holes = raid_mapLayer.features[i].attributes.holes;
  69. if(raidCenterCheck === true){
  70.  
  71. //var str = $('#topbar-container > div > div.location-info-region > div').text();
  72. var str = $('#topbar-container > div > div.topbar > div.location-info-region > div.location-info').text();
  73. var n2 = str.indexOf(" - ");
  74. if(n2 > 0){
  75. var n = str.length;
  76. var res = str.substring(n2+2, n);
  77. var rescount = res.indexOf(" - ");
  78. if(rescount>0){
  79. var n3 = res.length;
  80. var res2 = res.substring(rescount+2, n3);
  81. }
  82. var raidLocationLabel = '[Raid Group - ' + raid_mapLayer.features[i].attributes.number + '] - ' + res2;
  83.  
  84. } else {
  85. //var raidLocationLabel = '[Raid Group - ' + raid_mapLayer.features[i].attributes.number + '] - ' + $('#topbar-container > div > div.location-info-region > div').text();
  86. var raidLocationLabel = '[Raid Group - ' + raid_mapLayer.features[i].attributes.number + '] - ' + $('#topbar-container > div > div.topbar > div.location-info-region > div.location-info').text();
  87. }
  88. //setTimeout(function(){$('#topbar-container > div > div.location-info-region > div').text(raidLocationLabel);},200);
  89. setTimeout(function(){$('#topbar-container > div > div.topbar > div.location-info-region > div.location-info').text(raidLocationLabel);},200);
  90. if (holes === "false") { break; }
  91. }
  92. }
  93. }
  94.  
  95. function InitMapRaidOverlay(){
  96.  
  97. var mro_Map = Waze.map;
  98. var mro_OL = OpenLayers;
  99.  
  100. //if (!mro_Map) return;
  101. //if (!mro_OL) return;
  102.  
  103. var mro_mapLayers = mro_Map.getLayersBy("uniqueName","__TNMapraid");
  104. var raid_mapLayer = new mro_OL.Layer.Vector("TN Mapraid (Middle)", {
  105. displayInLayerSwitcher: true,
  106. uniqueName: "__TNMapraid"
  107. });
  108. I18n.translations.en.layers.name["__TNMapraid"] = "TN Mapraid (Middle)";
  109. mro_Map.addLayer(raid_mapLayer);
  110. raid_mapLayer.setVisibility(true);
  111.  
  112. 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'}];
  113. AddRaidPolygon(raid_mapLayer, VGroup1,"black","West TN");
  114.  
  115. //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'}];
  116. //AddRaidPolygon(raid_mapLayer, VGroup2,"black","Middle TN");
  117.  
  118. 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'}];
  119. AddRaidPolygon(raid_mapLayer, VGroup3,"black","East TN");
  120.  
  121. setTimeout(function(){CurrentRaidLocation(raid_mapLayer);},3000);
  122. mro_Map.events.register("moveend", Waze.map, function(){ setTimeout(function(){CurrentRaidLocation(raid_mapLayer);},1500);});
  123. mro_Map.events.register("zoomend", Waze.map, function(){ setTimeout(function(){CurrentRaidLocation(raid_mapLayer);},1500);});
  124. }

QingJ © 2025

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