Get OpenStreetMap Leaflet object

Get the Leaflet object of OpenStreetMap's website

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/533461/1589828/Get%20OpenStreetMap%20Leaflet%20object.js

  1. // ==UserScript==
  2. // @name Get OpenStreetMap Leaflet object
  3. // @match *://www.openstreetmap.org/*
  4. // @match *://www.opengeofiction.net/*
  5. // @match *://opengeofiction.net/*
  6. // @version 1.0
  7. // @author CyrilSLi
  8. // @description Get the Leaflet object of OpenStreetMap's website
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. unsafeWindow.userscriptMap = null;
  13. if (typeof L !== "undefined" && typeof L.Map !== "undefined") {
  14. L.Map.addInitHook(function () {
  15. if (this._container && this._container.id === "map") {
  16. unsafeWindow.userscriptMap = this;
  17. }
  18. });
  19. }