WMEExtResources

Links for opening external resources at the WME location

当前为 2017-08-31 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name WMEExtResources
  3. // @namespace https://greasyfork.org/users/30701-justins83-waze
  4. // @version 0.1
  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. var $section = $("<div>", {style:"padding:8px 16px"});
  19. $section.html([
  20. '<span id="GMaps">',
  21. '<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;">',
  22. '</span>'
  23. ].join(' '));
  24.  
  25. $('.WazeControlPermalink').append($section.html());
  26.  
  27. $('#GMapsImg').click(function(){
  28. let projI = new OpenLayers.Projection("EPSG:900913");
  29. let projE = new OpenLayers.Projection("EPSG:4326");
  30. let center_lonlat = (new OpenLayers.LonLat(Waze.map.center.lon, Waze.map.center.lat)).transform(projI,projE);
  31. let lat = Math.round(center_lonlat.lat * 1000000) / 1000000;
  32. let lon = Math.round(center_lonlat.lon * 1000000) / 1000000;
  33.  
  34. window.open('https://www.google.com/maps/@' + lat + ',' + lon + ',' + ( W.map.zoom + 12) + 'z', 'Google Maps');
  35. });
  36.  
  37. var $sectionMapillary = $("<div>", {style:"padding:8px 16px"});
  38. $sectionMapillary.html([
  39. '<span id="Mapillary">',
  40. '<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;">',
  41. '</span>'
  42. ].join(' '));
  43.  
  44. $('.WazeControlPermalink').append($sectionMapillary.html());
  45.  
  46. $('#MapillaryImg').click(function(){
  47. var projI=new OpenLayers.Projection("EPSG:900913");
  48. var projE=new OpenLayers.Projection("EPSG:4326");
  49. var center_lonlat = (new OpenLayers.LonLat(Waze.map.center.lon, Waze.map.center.lat)).transform(projI,projE);
  50. var lat = Math.round(center_lonlat.lat * 1000000) / 1000000;
  51. var lon = Math.round(center_lonlat.lon * 1000000) / 1000000;
  52.  
  53. window.open('https://www.mapillary.com/app/?lat=' + lat + '&lng=' + lon + '&z=' +( W.map.zoom + 12), 'Mapillary');
  54. });
  55.  
  56. }
  57.  
  58. function bootstrap(tries) {
  59. tries = tries || 1;
  60.  
  61. if (window.W &&
  62. window.W.map &&
  63. window.W.model &&
  64. $) {
  65. init();
  66. } else if (tries < 1000) {
  67. setTimeout(function () {bootstrap(tries++);}, 200);
  68. }
  69. }
  70.  
  71. bootstrap();
  72. })();