Map add nav canvas layer

From Sim Innovations Wiki
Jump to navigation Jump to search


layer_id = map_add_nav_canvas_layer(map_id, nav_type, x, y, width, height, draw_callback)

map_add_nav_canvas_layer is used to add a NAV canvas layer to an existing map. A certain number of NAV types are available (see below). For every NAV type, you are able to add a canvas.

Return value

Argument Type Description
layer_id ID This value can be used for further reference. Functions such as visible can use this layer_id. Its good practice to store this layer_id in your logic code.


# Argument Type Description
1 map_id Number The map_id to add the layer to. A map_id can be fetched by using function map_add.
2 nav_type String The NAV type to query, click here to see the NAV types page for all available types.
3 x Number The x pixel offset of where the canvas should be shown.
4 y Number The y pixel offset of where the canvas should be shown.
5 width Number The desired width of the canvas.
6 height Number The desired height of the canvas.
7 draw_callback String This function will be called on a redraw of the canvas.


-- Place a map to your instrument using the openstreetmap cycle map and zoom level of 10
map_id = map_add(0, 0, 512, 512, "OSM_CYCLE", 10)

-- Add the canvas draw callback
function canvas_draw_callback(vhf_navaid_data)
  _circle(25, 25, 25)
  _txt(vhf_navaid_data["ICAO"], "font:roboto_bold.ttf; size:16; color: black; halign:center; valign:center", 25, 25)

-- Add a NAV layer of type "VHF_NAVAID". For every VHF_NAVAID station the canvas draw callback will be called.
layer_id = map_add_nav_canvas_layer(map_id, "AIRPORT", -25, -25, 50, 50, canvas_draw_callback)

map_goto(map_id, 52.422607, 5.485053)