Canvas Map API: Difference between revisions

Jump to navigation Jump to search
Line 240: Line 240:


Note that the model merely stores the data - only the draw* callback will try to access it, i.e. the lat/lon/id fields.
Note that the model merely stores the data - only the draw* callback will try to access it, i.e. the lat/lon/id fields.
Also, the LayerModel class is currently just an extremely simple wrapper, all of its fields/methods are directly available to you:
<syntaxhighlight lang="php">
##
# A layer model is just a wrapper for a vector with elements
# either updated via a timer or via a listener
var LayerModel = {_elements:[] };
LayerModel.new = func make(LayerModel);
LayerModel.clear = func me._elements = [];
LayerModel.push = func (e) append(me._elements, e);
LayerModel.get = func me._elements;
LayerModel.update = func;
LayerModel.hasData = func size(me. _elements);
</syntaxhighlight>
That is, you have the following methods available:
* new() - to create a new LayerModel instance
* clear() - to clear the internal _elements vector
* push() - to append new data to the internal _elements vector
* get() - to get a handle to the internal _elements vector
* update() - empty placeholder for the time being
* hasData() - to get the size of the internal _elements vector (beginning at 0)


Now, to actually make a new layer known to the system, we need to add another file that registers the layer. For an example of how to do this, please see navaids.layer:
Now, to actually make a new layer known to the system, we need to add another file that registers the layer. For an example of how to do this, please see navaids.layer:

Navigation menu