Canvas Map API: Difference between revisions

Jump to navigation Jump to search
m
m (prepare for changes for Hyde's 777 EFB: http://flightgear.org/forums/viewtopic.php?f=71&t=21139&p=192249#p192249)
Line 207: Line 207:


Required:
Required:
* callback to draw a single layer element (aircraft, waypoint, navaid, runway)
* callback to draw a single layer element (aircraft, waypoint, navaid, runway, route, fixes etc)
* A new class (Nasal hash) that derives from the "Layer" class and implements its interface
* A new class (Nasal hash) that derives from the "Layer" class and implements its interface
* A "data source" (provider) hash that provides the data to be rendered (i.e. populates the model)
* A "data source" (provider) hash that provides the data to be rendered (i.e. populates the model, which is just a Nasal vector of drawables)




Line 244: Line 244:


As you can see, the draw* callback takes three arguments:
As you can see, the draw* callback takes three arguments:
* the canvas group/layer to be used
* the canvas group/layer to be used as the rendering target
* the layer-specific "model" information (airport/apt in this case, could also be a navaid, fix or waypoint)
* the layer-specific "model" information (airport/apt in this case, could also be a navaid, fix or waypoint)
* an LOD argument (currently not yet used).
* an LOD argument (currently not yet used).
Line 284: Line 284:
In this case, the init() method merely clears the internal vector using the "me.clear()" call, runs findNavaidsWithinRange(50); and then populates the model by appending each navaid to the MVC model in the top-level "LayerModel". Afterwards, the "notifyView" method is invoked to update the view (this will probably change pretty soon, once a real MVC controller abstraction is added).
In this case, the init() method merely clears the internal vector using the "me.clear()" call, runs findNavaidsWithinRange(50); and then populates the model by appending each navaid to the MVC model in the top-level "LayerModel". Afterwards, the "notifyView" method is invoked to update the view (this will probably change pretty soon, once a real MVC controller abstraction is added).


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 or anything else that is model specific.


Also, the LayerModel class is currently just an extremely simple wrapper, all of its fields/methods are directly available to you:
Also, the LayerModel class is currently just an extremely simple wrapper, all of its fields/methods are directly available to you:

Navigation menu