I\'m trying to change some things on a map that is already initialised by another script, using the Leaflet library. This other script did not store the map-object in a glob
For the record, in case you have the possibility to inject / execute some JS code before the map is initialized (i.e. before the "other script" executes), you can very easily customize Leaflet to keep a reference to each created maps.
E.g. using the addInitHook constructor hook on L.Map
class:
// Before map is being initialized.
var mapsPlaceholder = [];
L.Map.addInitHook(function () {
mapsPlaceholder.push(this); // Use whatever global scope variable you like.
});
// "Other script", can be in its own separate