diff --git a/Nasal/canvas/MapStructure.nas b/Nasal/canvas/MapStructure.nas index b75b021bb..55acf899e 100644 --- a/Nasal/canvas/MapStructure.nas +++ b/Nasal/canvas/MapStructure.nas @@ -83,7 +83,7 @@ var MapStructure_selfTest = func() { TestMap.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, visible: type.vis, priority: type.zindex, ); - foreach(var type; [ r('OSM'), r('OpenAIP') ]) { + foreach(var type; [ r('OSM'), r('OpenAIP'), r('STAMEN') ]) { TestMap.addLayer(factory: canvas.OverlayLayer, type_arg: type.name, visible: type.vis, priority: type.zindex, style: Styles.get(type.name), diff --git a/Nasal/canvas/map/STAMEN.lcontroller b/Nasal/canvas/map/STAMEN.lcontroller new file mode 100644 index 000000000..6a9623a8d --- /dev/null +++ b/Nasal/canvas/map/STAMEN.lcontroller @@ -0,0 +1,43 @@ +# See: http://wiki.flightgear.org/MapStructure +# Class things: +var name = 'STAMEN'; +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('http://b.tile.stamen.com/terrain/{z}/{x}/{y}.png'); + layer.makePath = string.compileTemplate(layer.maps_base ~ '/stamen-terrain/{z}/{x}/{y}.png'); + + #layer.makeURL = string.compileTemplate('http://b.tile.stamen.com/terrain-background/{z}/{x}/{y}.png'); + #layer.makePath = string.compileTemplate(layer.maps_base ~ '/stamen-terrain-background/{z}/{x}/{y}.png'); + + #layer.makeURL = string.compileTemplate('http://b.tile.stamen.com/toner/{z}/{x}/{y}.png'); + #layer.makePath = string.compileTemplate(layer.maps_base ~ '/stamen-toner/{z}/{x}/{y}.png'); + + + m.addVisibilityListener(); + m.addRangeListener(); + m.addScreenRangeListener(); + return m; +}; + +var updateLayer = func() { +} + +var del = func() { + foreach (var l; me.listeners) + removelistener(l); +}; diff --git a/gui/dialogs/map-canvas.xml b/gui/dialogs/map-canvas.xml index 3bf7cfc8d..71fab3fb5 100644 --- a/gui/dialogs/map-canvas.xml +++ b/gui/dialogs/map-canvas.xml @@ -296,6 +296,20 @@ + + + left + + /sim/gui/dialogs/map-canvas/draw-STAMEN + true + + dialog-apply + + + property-toggle + + +