WMEExtResources

Links for opening external resources at the WME location

目前为 2017-11-07 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WMEExtResources
  3. // @namespace https://greasyfork.org/users/30701-justins83-waze
  4. // @version 2017.11.07.01
  5. // @description Links for opening external resources at the WME location
  6. // @author JustinS83
  7. // @include https://www.waze.com/editor*
  8. // @include https://www.waze.com/*/editor*
  9. // @include https://beta.waze.com*
  10. // @exclude https://www.waze.com/user/editor*
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. function init(){
  18. $('.olControlAttribution').css("right", "300px");
  19. var $section = $("<div>", {style:"padding:8px 16px"});
  20. $section.html([
  21. '<span id="GMaps">',
  22. '<img src="http://i.imgur.com/whsQQFE.png" alt="Google Maps" width="18" height="18" id="GMapsImg" title="Open in Google Maps" style="cursor:pointer; float: left; display:inline-block; margin: 2px 5px 0 3px;">',
  23. '</span>'
  24. ].join(' '));
  25.  
  26. $('.WazeControlPermalink').append($section.html());
  27.  
  28. $('#GMapsImg').click(function(){
  29. let projI = new OpenLayers.Projection("EPSG:900913");
  30. let projE = new OpenLayers.Projection("EPSG:4326");
  31. let center_lonlat = (new OpenLayers.LonLat(Waze.map.center.lon, Waze.map.center.lat)).transform(projI,projE);
  32. let lat = Math.round(center_lonlat.lat * 1000000) / 1000000;
  33. let lon = Math.round(center_lonlat.lon * 1000000) / 1000000;
  34. let lang = I18n.currentLocale().replace("en-US", "en");
  35.  
  36. window.open('https://www.google.com/maps/@' + lat + ',' + lon + ',' + ( W.map.zoom + 12) + 'z' + (lang != "" ? "?hl=" + lang : ""), 'Google Maps');
  37.  
  38. });
  39.  
  40. var $sectionMapillary = $("<div>", {style:"padding:8px 16px"});
  41. $sectionMapillary.html([
  42. '<span id="Mapillary">',
  43. '<img src="https://i.imgur.com/vG2qieS.png" alt="Mapillary" width="18" height="18" id="MapillaryImg" title="Open in Mapillary" style="cursor:pointer; float: left; display:inline-block; margin: 2px 5px 0 3px;">',
  44. '</span>'
  45. ].join(' '));
  46.  
  47. $('.WazeControlPermalink').append($sectionMapillary.html());
  48.  
  49. $('#MapillaryImg').click(function(){
  50. var projI=new OpenLayers.Projection("EPSG:900913");
  51. var projE=new OpenLayers.Projection("EPSG:4326");
  52. var center_lonlat = (new OpenLayers.LonLat(Waze.map.center.lon, Waze.map.center.lat)).transform(projI,projE);
  53. var lat = Math.round(center_lonlat.lat * 1000000) / 1000000;
  54. var lon = Math.round(center_lonlat.lon * 1000000) / 1000000;
  55.  
  56. window.open('https://www.mapillary.com/app/?lat=' + lat + '&lng=' + lon + '&z=' +( W.map.zoom + 11), 'Mapillary');
  57. });
  58.  
  59. var $sectionTerraserver = $("<div>", {style:"padding:8px 16px"});
  60. $sectionTerraserver.html([
  61. '<span id="Terraserver">',
  62. '<img src="https://imgur.com/IPUFNnR.png" alt="Terraserver" width="18" height="18" id="TerraserverImg" title="Open in Terraserver" style="cursor:pointer; float: left; display:inline-block; margin: 2px 5px 0 3px;">',
  63. '</span>'
  64. ].join(' '));
  65.  
  66. $('.WazeControlPermalink').append($sectionTerraserver.html());
  67.  
  68. $('#TerraserverImg').click(function(){
  69. var center_lonlat=OpenLayers.Layer.SphericalMercator.inverseMercator(Waze.map.getCenter().lon,Waze.map.getCenter().lat);
  70. window.open('http://www.terraserver.com/view?utf8=✓&searchLng='+center_lonlat.lon+'&searchLat='+center_lonlat.lat);
  71. });
  72. }
  73.  
  74. function bootstrap(tries) {
  75. tries = tries || 1;
  76.  
  77. if (window.W &&
  78. window.W.map &&
  79. window.W.model &&
  80. $) {
  81. init();
  82. } else if (tries < 1000) {
  83. setTimeout(function () {bootstrap(tries++);}, 200);
  84. }
  85. }
  86.  
  87. bootstrap();
  88. })();