# Class: Framework

## vcs.vcm.Framework

The main Framework class This class is a Singleton, to get an instance call vcs.vcm.Framework.getInstance(); This class manages the following points

- loading of the config file
- creation and management of the map, layer, viewpoints and widget objects
- analysis of the URL parameter and forwarding to the widgets
- Message system (publish, subscribe)

The default way to initialize a map is by running:

            vcs.vcm.Framework.getInstance();
            vcs.vcm.Framework.activateLogging();
            vcs.vcm.Framework.loadConfig("http://www.location.to/config.json");

The structure of the config json is presented under the `vcs.vcm.Framework.init` method

#### new vcs.vcm.Framework()

### Members

#### isIE11{boolean}

  Whether this is IE11 or not

### Methods

#### vcs.vcm.Framework.activateLogging()

  activates the logging window.

  Deprecated
    - Yes

#### vcs.vcm.Framework.dispose()

  disposes of the Framework

#### vcs.vcm.Framework.getInstance(){vcs.vcm.Framework}

  Singleton getter for this class

#### vcs.vcm.Framework.getObjectFromOptions(options){Object}

  returns a constructor of a type.

  Name | Type | Description
  --- | --- | ---
  `options` | Object |

#### vcs.vcm.Framework.getVersion(){string}

  returns the version of the framework

#### vcs.vcm.Framework.init(config)

  evaluates the returned config Object creates maps, layers, widgets, and viewpoint objects

  Name | Type | Description
  --- | --- | ---
  - `config` | Object | Object literal with the following parameters mapcontainer: `string` dom id of the mapcontainer startViewPoint: `string` name of the viewpoint to start the map with. The associated viewpoint must be defined under "viewpoints" projection : `Object` the default projection to use for display/input of coordinates to/from the user. See `vcs.vcm.util.Projection` selectBehavior : `Object` Defines the select behavior for buildings, vectors etc. See `vcs.vcm.SelectBehavior` widgets: `Array(Object)` Each object literals defines one `vcs.vcm.widgets.Widget` configuration. maps: `Array(Object)` Each object literal represents one `vcs.vcm.maps.Map` configuration layers: `Array(Object)` Each object literal in the array consists of one `vcs.vcm.layer.Layer` configuration viewpoints: `Array(Object)` Each object literal in the array consists of one `vcs.vcm.util.ViewPoint` configuration availableLocales `Array(string)` The available locales in the map. If one or omitted, no language selection is available in the map locale: `string` language token (de, en, pl, nl), determines the default language ui: `Object` ui Configuration for UI part, see example Configuration file for i18n: `Object` Can be used to overwrite existing i18n entries or add new ones which can be used for example in a balloon. For example: to include a translation in a balloon for the word "building" use
                "i18n" : {
                     "en" : {
                         "i18n_building" : "Building"
                     },
                     "de" : {
                         "i18n_building" : "Gebauede"
                     }
                }
    If now a balloon is defined with a template which includes:
                <div class="i18n_building"> </div>
  The innerText of this element will be filled with the appropriate translation. Make sure to the classname always starts with "i18n_" To overwrite existing translations, check which i18n_.. class is attached to the element and overwrite.

#### vcs.vcm.Framework.loadConfig(url)

  starts the framework from an external config.json file. After ajax loading the config file "init" is called with the loaded data.

  Name | Type | Description
  --- | --- | ---
  `url` | string | the url of the config json file

#### activateMap(name, optViewpoint)

  Deactivates the current active map, and activates the map with the given name. The new map uses the current viewpoint of the currently active map or -if specified- uses the opt_viewpoint

  Name | Type | Description
  --- | --- | ---
  `name` | string |
  `optViewpoint` | vcs.vcm.util.ViewPoint | optional starting Viewpoint

#### addFlight(flight)

  Name | Type | Description
  --- | --- | ---
  `flight` | vcs.vcm.util.flight.FlightInstance |

#### addLayer(layer){boolean}

  add Layer to the Framework

  Name | Type | Description
  --- | --- | ---
  `layer` | vcs.vcm.layer.Layer |

  ##### Returns:

  returns true if the layer has been added, false otherwise, check the logs for the cause

#### addMap(map){boolean}

  adds a map to the framework. If the startingmap config value is set to true the activate function of the map is called.

  Name | Type | Description
  --- | --- | ---
  `map` | vcs.vcm.maps.Map |

  ##### Returns:

  true/false if the map has been added.

#### addStyle(style)

  adds a style to the framework

  Name | Type | Description
  --- | --- | ---
  `style` | vcs.vcm.util.style.StyleItem |

#### addViewPoint(viewpoint)

  returns the viewpoints as an array

  Name | Type | Description
  --- | --- | ---
  `viewpoint` | vcs.vcm.util.ViewPoint |

#### addWidget(widget){boolean}

  adds a widget to the framework.

  Name | Type | Description
  --- | --- | ---
  `widget` | vcs.vcm.widgets.Widget |

  ##### Returns:

  returns true if the widget has been added, otherwise false;

#### dispose()

  destroys the framework instance framework

#### getActiveMap(){vcs.vcm.maps.Map}

  returns the currently active Map

#### getConfig(path){Object}

  returns the config

  Name | Type | Description
  --- | --- | ---
  `path` | string | the config path to checkout, use dots for nested keys ( if not given, the whole config is returned)

#### getFlightByName(name){vcs.vcm.util.flight.FlightInstance}

  Name | Type | Description
  --- | --- | ---
  `name` | string |

#### getFlights(){Array.<vcs.vcm.util.flight.FlightInstance>}

#### getI18nConfig(){Object}

  returns the i18n information

#### getLayerByName(name){vcs.vcm.layer.Layer}

  returns the layer with the given name

  Name | Type | Description
  --- | --- | ---
  `name` | string | layer name

#### getLayers(){Array.<vcs.vcm.layer.Layer>}

  returns all Layer

  ##### Returns:

  layers

#### getLocale(){string}

  returns the current locale

  ##### Returns:

  the current locale

#### getLocales(){Array.<string>}

  returns possible locales

  ##### Returns:

  the current locale

#### getMapByName(name){vcs.vcm.maps.Map}

  returns a map

  Name | Type | Description
  --- | --- | ---
  `name` | string |

#### getMapByType(className){vcs.vcm.maps.Map}

  returns a map based on the given type

  Name | Type | Description
  --- | --- | ---
  `className` | string |

#### getMapContainer(){HTMLElement}

  returns the Mapcontainer, here the different maps add themselves as children.

#### getMaps(){Array.<vcs.vcm.maps.Map>}

  returns an array of maps in the framework

#### getProjection(){vcs.vcm.util.Projection}

  returns the projection

#### getSelectBehavior(){vcs.vcm.SelectBehavior}

  returns the selectBehavior, if no selectBehavior returns null

#### getStartViewPoint(){vcs.vcm.util.ViewPoint}

  returns the starting viewpoint or null if none is set

#### getStyleByName(name){vcs.vcm.util.style.StyleItem}

  Returns the given style

  Name | Type | Description
  --- | --- | ---
  `name` | string |

#### getViewPointByName(name){vcs.vcm.util.ViewPoint}

  returns the viewpoint with the given name

  Name | Type | Description
  --- | --- | ---
  `name` | string | the viewpoint name

#### getViewPoints(){Array.<vcs.vcm.util.ViewPoint>}

  returns the viewpoints as an array

#### getWidgetByName(name){vcs.vcm.widgets.Widget|null}

  returns a Widget with the given name

  Name | Type | Description
  --- | --- | ---
  `name` | string | widget Name

  Deprecated
    - Yes

#### getWidgetByType(type){vcs.vcm.widgets.Widget|undefined}

  returns the first widget with the given type

  Name | Type | Description
  --- | --- | ---
  `type` | string | the type of the widget

#### getWidgets(){Array.<vcs.vcm.widgets.Widget>}

  returns all widgets

#### getWidgetsByType(type){Array.<vcs.vcm.widgets.Widget>}

  returns an array of Widgets with the given type

  Name | Type | Description
  --- | --- | ---
  `type` | string | widget type

#### isInitialized(){boolean}

  returns if the framework has been initialized;

#### isMobile(){boolean}

  returns true if we are on a mobile device including tablets

#### loadLibraries(sources, dontuseBasePath){Promise}

  can be used to load one or more additional external libraries. Returns a Promise if all library are loaded.

  framework.loadLibraries(["jquery.js"]).then(function(){ use jquery... });

  Name | Type | Description
  --- | --- | ---
  `sources` | Array.<string> |
  `dontuseBasePath` | boolean |

#### publish(topic, opt_data)

  Publishes a message to a topic. Calls functions subscribed to the topic in the order in which they were added, passing all arguments along.

  Name | Type | Description
  --- | --- | ---
  `topic` | string | vcs.vcm.event.EventType | Topic to publish to.
  `data` | any | Arguments that are applied to each subscription function.

#### removeLayerByName(name)

  remove Layer from Framework and calls dispose on layer

  Name | Type | Description
  --- | --- | ---
  `name` | string |

#### setLocale(lang)

  sets the current locale

  Name | Type | Description
  --- | --- | ---
  `lang` | string |

#### setProjection(projection)

  sets the projection

  Name | Type | Description
  --- | --- | ---
  `projection` | vcs.vcm.util.Projection |

#### setStartViewPoint(viewpoint)

  sets the startview for automatically loading maps, has to be set before map activation

  Name | Type | Description
  --- | --- | ---
  `viewpoint` | vcs.vcm.util.ViewPoint |

#### subscribe(topic, handler, optContext){number}

  Subscribes a function to a topic

  Name | Type | Description
  --- | --- | ---
  `topic` | string | vcs.vcm.event.EventType | Topic to subscribe to.
  `handler` | function | Function to be invoked when a message is published to the given topic.
  `optContext` | Object | Object in whose context the function is to be called (the global scope if none).

  ##### Returns:

  Subscription key, can be used to unsubscribe

#### subscribeExclusive(topic, handler, id, removed, optContext){number}

  Subscribes a function to an exclusive topic, deactivating the previous function

  Name | Type | Description
  --- | --- | ---
  `topic` | string | vcs.vcm.event.EventType | Topic to subscribe to.
  `handler` | function | Function to be invoked when a message is published to the given topic.
  `id` | string | a UUID to identify the exclusive caller
  `removed` | function | Function to be invoked when the listener is removed
  `optContext` | Object | Object in whose context the function is to be called (the global scope if none).

  ##### Returns:

  Subscription key, can be used to unsubscribe

#### subscribeOnce(topic, handler, optContext){number}

  Subscribes a single-use function to a topic. The function is only called once and automatically unsubscribed.

  Name | Type | Description
  --- | --- | ---
  `topic` | string | vcs.vcm.event.EventType | Topic to subscribe to.
  `handler` | function | Function to be invoked once and then unsubscribed when a message is published to the given topic.
  `optContext` | Object | Object in whose context the function is to be called (the global scope if none).

  ##### Returns:

  Subscription key, can be used to unsubscribe

#### subscribeOnceExclusive(topic, handler, id, removed, optContext){number}

  Subscribes a single-use function to an exclusive topic, deactivating the previous function

  Name | Type | Description
  --- | --- | ---
  `topic` | string | vcs.vcm.event.EventType | Topic to subscribe to.
  `handler` | function | Function to be invoked when a message is published to the given topic.
  `id` | string | a UUID to identify the exclusive caller
  `removed` | function | Function to be invoked when the listener is removed
  `optContext` | Object | Object in whose context the function is to be called (the global scope if none).

  ##### Returns:

  Subscription key, can be used to unsubscribe

#### unsubscribeByKey(key)

  Unsubscribes a function from a topic by a key. Only deletes the first match found.

  Name | Type | Description
  --- | --- | ---
  `key` | number | key to unsubscribe