# See: http://wiki.flightgear.org/MapStructure
# Class things:
var name = 'OSM';
var parents = [OverlayLayer.Controller];
var __self__ = caller(0)[0];
OverlayLayer.Controller.add(name, __self__);
TileLayer.add(name, {
	parents: [TileLayer],
	type: name, # Layer type
	df_controller: __self__, # controller to use by default -- this one
});

var new = func(layer) {
	var m = {
		parents: [__self__],
		layer: layer,
		map: layer.map,
		listeners: [],
	};

	layer.makeURL = string.compileTemplate('https://maps.wikimedia.org/osm-intl/{z}/{x}/{y}.png');
	layer.makePath = string.compileTemplate(layer.maps_base ~ '/osm-intl/{z}/{x}/{y}.png');

	layer.max_zoom = 18;
	layer.min_zoom = 1;

	m.addVisibilityListener();
	m.addRangeListener();
	m.addScreenRangeListener();
	return m;
};

var updateLayer = func() {
}

var del = func() {
	#print(name~".lcontroller.del()");
	foreach (var l; me.listeners)
		removelistener(l);
};