Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
MapStructure Stame
diff --git a/Nasal/canvas/MapStructure.nas b/Nasal/canvas/MapStructure.nas
index 78334d1..66a14b6 100644
--- a/Nasal/canvas/MapStructure.nas
+++ b/Nasal/canvas/MapStructure.nas
@@ -83,7 +83,7 @@
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 0000000..f23b886
--- /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 10cd6e4..c6d5ca5 100644
--- a/gui/dialogs/map-canvas.xml
+++ b/gui/dialogs/map-canvas.xml
@@ -244,6 +244,20 @@
</binding>
</checkbox>
+ <checkbox>
+ <label>STAMEN</label>
+ <halign>left</halign>
+
+ <property>/sim/gui/dialogs/map-canvas/draw-STAMEN</property>
+ <live>true</live>
+ <binding>
+ <command>dialog-apply</command>
+ </binding>
+ <binding>
+ <command>property-toggle</command>
+ </binding>
+ </checkbox>
+
<!-- layer only supported if tutorial system is active and targets specified-->
<!--
@@ -489,7 +503,7 @@
})();
}
- 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: 1,
style: Styles.get(type.name),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.