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.06.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", "275px");
  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. }
  60.  
  61. function bootstrap(tries) {
  62. tries = tries || 1;
  63.  
  64. if (window.W &&
  65. window.W.map &&
  66. window.W.model &&
  67. $) {
  68. init();
  69. } else if (tries < 1000) {
  70. setTimeout(function () {bootstrap(tries++);}, 200);
  71. }
  72. }
  73.  
  74. bootstrap();
  75. })();