New plugin add a pan control to the map
This commit is contained in:
52
plugins/pan-control.user.js
Normal file
52
plugins/pan-control.user.js
Normal file
@ -0,0 +1,52 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-pan-control@fragger
|
||||
// @name IITC plugin: pan control
|
||||
// @version 0.1.0.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description [@@BUILDNAME@@-@@BUILDDATE@@] Shows a panning control on the map
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
// @match https://www.ingress.com/intel*
|
||||
// @match http://www.ingress.com/intel*
|
||||
// ==/UserScript==
|
||||
|
||||
function wrapper() {
|
||||
// ensure plugin framework is there, even if iitc is not yet loaded
|
||||
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||
|
||||
|
||||
// PLUGIN START ////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// use own namespace for plugin
|
||||
window.plugin.panControl = function() {};
|
||||
|
||||
window.plugin.panControl.setup = function() {
|
||||
try { console.log('Loading Leaflet.Pancontrol JS now'); } catch(e) {}
|
||||
@@INCLUDERAW:external/L.Control.Pan.js@@
|
||||
try { console.log('done loading Leaflet.Pancontrol JS'); } catch(e) {}
|
||||
|
||||
window.map.addControl(L.control.pan({panOffset: 350}));
|
||||
|
||||
$('head').append('<style>@@INCLUDESTRING:external/L.Control.Pan.css@@</style>');
|
||||
};
|
||||
|
||||
var setup = window.plugin.panControl.setup;
|
||||
|
||||
// PLUGIN END //////////////////////////////////////////////////////////
|
||||
|
||||
if(window.iitcLoaded && typeof setup === 'function') {
|
||||
setup();
|
||||
} else {
|
||||
if(window.bootPlugins)
|
||||
window.bootPlugins.push(setup);
|
||||
else
|
||||
window.bootPlugins = [setup];
|
||||
}
|
||||
} // wrapper end
|
||||
// inject code into site context
|
||||
var script = document.createElement('script');
|
||||
script.appendChild(document.createTextNode('('+ wrapper +')();'));
|
||||
(document.body || document.head || document.documentElement).appendChild(script);
|
Reference in New Issue
Block a user