JavaScript Objects and Classes

The design of CanvasMap is based on Object Oriented Design principles implemented with JavaScript and the Document Object Model (DOM).

JavaScript Object Containment

The figure below shows how CanvasMap aggregations or contains it's JavaScript objects and DOM elements. All the JavaScript objects are contained within an overall CanvasMap object. This is the primary object to use. The CanvasMap object then contains a "Scene" which contains "Layers". The Scene can be thought of as a scene or area on the ground and is the same as a Scene in BlueSpray or a "Data Frame" in ArcGIS. The layers contain the actual spatial data. There can be a variety of types of layers and you are welcome to create your own. The layers are linked to their entries in the "Layer List" called "Layers Element". The Scene also contains the "Views" that the Scene appears in. The Views are linked to the HTML Canvas element that they will draw into. There are also a variety of support classes for putting up JavaScript "Dialog Boxes", projecting data, and other utility functions.

The aggregation hierarchy for CanvasMap

Files

All files are prefixed with "CM" for "CanvasMap". This is to reduce collisions with other JavaScript libraries.

The JavaScript files follow the same naming convention as show in the diagram above. Each file contains one class which is the same name as the file it is in. When a new class is created, it uses the name of its superclass to start its name. Thus, STLayerGeoJSON inherits from STLayer. This means all the functions that are available in an STLayer are also available in an STLayerGeoJSON class. The STLayerGeoJSON class will then replace or "override" the functions it needs to in STLayer.

Inheritance

The inheritence for STLayer is:

Other layer types are in the works and you can easily create your own by overriding the functions in CMLayer.

There is a similar inheritance tree for projectors: