Canvas snippets: Difference between revisions

Jump to navigation Jump to search
Line 555: Line 555:
| {{Note|This assumes that you already have a top-level root group set up, and named it '''root''', just change this variable if you want it to be rendered elsewhere. Equally, this snippet assumes that your canvas is named '''myCanvas'''.}}
| {{Note|This assumes that you already have a top-level root group set up, and named it '''root''', just change this variable if you want it to be rendered elsewhere. Equally, this snippet assumes that your canvas is named '''myCanvas'''.}}
<syntaxhighlight lang="nasal" enclose="div">
<syntaxhighlight lang="nasal" enclose="div">
var TestMap = root.createChild("map");
TestMap.setController("Aircraft position");
TestMap.setRange(25);
TestMap.setTranslation(    myCanvas.get("view[0]")/2,
                          myCanvas.get("view[1]")/2
                        );
var r = func(name,vis=1,zindex=nil) return caller(0)[0];
var type = r('APT');
var style_apt = {
    scale_factor:0.5,
    color_default:[0,1,0.9],
    line_width:4,
    label_font_color:[0,1,0.9],
    label_font_size:30
};
TestMap.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, visible: type.vis, priority: type.zindex,style:style_apt);
var type = r('VOR');
var style_vor = {
    scale_factor:0.5,
    color:[0.1,0.9,0],
    line_width:4,
    text_color:[0.1,0.9,0]
};
TestMap.addLayer(factory: canvas.SymbolLayer, type_arg: type.name, visible: type.vis, priority: type.zindex,style:style_vor);
### See ...fgdata/Nasal/canvas/map/APT.symbol  ...fgdata/Nasal/canvas/map/VOR.style ... for the style variables that can be configured.
</syntaxhighlight>
</syntaxhighlight>


|}
|


== Using MapStructure and Overlays ==
== Using MapStructure and Overlays ==
29

edits

Navigation menu