Skip to content

Instantly share code, notes, and snippets.

@McBen
Last active June 4, 2024 03:54
Show Gist options
  • Save McBen/30761c55a8e409969c1eaab62c136537 to your computer and use it in GitHub Desktop.
Save McBen/30761c55a8e409969c1eaab62c136537 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @author mcben
// @name IITC plugin: OpenStreetMap Transportation
// @category Map Tiles
// @version 1.0.1
// @description Add the OpenStreetMap transporation map tiles
// @id basemap-opvn
// @namespace https://github.com/IITC-CE/ingress-intel-total-conversion
// @match https://intel.ingress.com/*
// @match https://intel-x.ingress.com/*
// @grant none
// ==/UserScript==
function wrapper(plugin_info) {
// ensure plugin framework is there, even if iitc is not yet loaded
if(typeof window.plugin !== 'function') window.plugin = function() {};
//PLUGIN AUTHORS: writing a plugin outside of the IITC build environment? if so, delete these lines!!
//(leaving them in place might break the 'About IITC' page or break update checks)
plugin_info.buildName = 'local';
plugin_info.dateTimeVersion = '2024-04-04-045100';
plugin_info.pluginId = 'basemap-opvn';
//END PLUGIN AUTHORS NOTE
/* exported setup, changelog --eslint */
/* global L, layerChooser */
// use own namespace for plugin
var mapOpnvMap = {};
window.plugin.mapOpnvMap = mapOpnvMap;
var changelog = [
];
// https://www.xn--pnvkarte-m4a.de
// Common options
var osmOpt = {
attribution: 'Karte memomaps.de CC-BY-SA, © Openstreetmap ODbL',
maxNativeZoom: 18,
maxZoom: 21,
};
mapOpnvMap.LAYERS = [
{
name: 'Transportation-Map',
url: 'https://tileserver.memomaps.de/tilegen/{z}/{x}/{y}.png',
options: Object.assign({}, osmOpt),
}
];
function setup() {
for (var entry of mapOpnvMap.LAYERS) {
var layer = new L.TileLayer(entry.url, entry.options);
layerChooser.addBaseLayer(layer, entry.name);
}
}
setup.info = plugin_info; //add the script info data to the function as a property
if (typeof changelog !== 'undefined') setup.info.changelog = changelog;
if(!window.bootPlugins) window.bootPlugins = [];
window.bootPlugins.push(setup);
// if IITC has already booted, immediately run the 'setup' function
if(window.iitcLoaded && typeof setup === 'function') setup();
} // wrapper end
// inject code into site context
var script = document.createElement('script');
var info = {};
if (typeof GM_info !== 'undefined' && GM_info && GM_info.script) info.script = { version: GM_info.script.version, name: GM_info.script.name, description: GM_info.script.description };
script.appendChild(document.createTextNode('('+ wrapper +')('+JSON.stringify(info)+');'));
(document.body || document.head || document.documentElement).appendChild(script);
@Artoria2e5
Copy link

Artoria2e5 commented May 28, 2024

window.plugin.mapOpenStreetMap = mapOpnvMap;

looks a little fishy; you might want

window.plugin.mapOpnvMap= mapOpnvMap;

(I'm trying to figure out why it doesn't load on my iOS IITC build. Probably not because of this.)

@McBen
Copy link
Author

McBen commented May 28, 2024

window.plugin.mapOpnvMap= mapOpnvMap;

thx, fixed.

@McBen
Copy link
Author

McBen commented May 28, 2024

I'm trying to figure out why it doesn't load on my iOS IITC build. Probably not because of this

maybe the localized layername "öpnv " (öffentlicher PersonenNahVerkehr) - I would try changing line 47

Most other stuff is simply copy&paste from Openstreetmap plugin. All was done in hotel room while at the Porto-Anomaly

@Artoria2e5
Copy link

I... must apologize. I simply forgot to turn it on. The original version works, so does the new one. This is embarassing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment