Nokia Maps API Reference

Contents

Class nokia.Features

Class Summary

This class provides facilities that allow you to register and load individual functional components (features) of the API. It automatically resolves dependencies between features and provides mechanisms to detect the best feature implementation for the current environment. A feature may exist in different implementations for different target environments. A feature implementation is a set of classes that provide certain functionality and can be loaded to enrich the functionality set accessible through the API. The features that can be loaded individually with the help of the methods on this class include such components as "routing" and "search".

By default, the API loads all possible features in the optimal implementation for the environment in which it runs. However, the loading of certain features may also be deferred by explicitly disallowing certain or all features at page-load time. This may reduce the initial page load time by limiting the amount of API code that is transferred and executed before the page contents are fully displayed.

Features is a static object that cannot be instantiated, therefore to call one of its methods, you must precede the method name with the namespace and the name of the class, using the dot notation. For example, you can call the load() method as follows (we assume that the argument refers to a real map object as described in the documentation for load()):

nokia.Features.load(myMapOfFeautesToLoad);

Method Summary
static add (featureName, featureImplName, loadPath, [detector, [dependencies, [overrides, [charset]]]]) This method adds a new feature implementation definition to the feature registry.
static get (featureName, [featureImplName]) This method retrieves a feature implementation definition object for the feature specified by the caller.
static getFeatureMap () This method retrieves a map object containing the names of available implementations for each registered feature.
static getLoadedMap () This method retrieves a map of the names of fully loaded implementations for each registered feature.
static isLoaded (featureName, featureImplName) : Boolean This method checks whether a certain feature implementation has been successfully loaded.
static load (requested, [onSuccess, [onError, [doc, [sync]]]]) This method loads a set of features specified by the caller.
Method Detail
static add (featureName, featureImplName, loadPath, [detector, [dependencies, [overrides, [charset]]]])
This method adds a new feature implementation definition to the feature registry. If the feature does not yet exist in the registry, an entry for it is created, including the feature name and the implementation and the implementation object.
Parameters:
{string} featureName A canonical name of the feature which the implementation provides
{string} featureImplName A canonical the name of the implementation
{string} loadPath The load path of the implementation file
{function ()} [detector]: The detector function that determines whether this feature can be loaded in the current environment; if a detector is not provided, a default function that always returns true is used
{Array} [dependencies]: null An optional array of the names of the features on which the named implementation depends
{Array} [overrides]: null An optional array of implementation names (within the same feature) this implementation overrides.
{string} [charset]: 'utf-8' An optional identifier of the character set for the script
static get (featureName, [featureImplName])
This method retrieves a feature implementation definition object for the feature specified by the caller.
Parameters:
{string} featureName The name of the feature to be retrieved
{string} [featureImplName]: 'auto' Either the name of the specific implementation or 'auto', which allows the method automatically to detect the optimal implementation for the current environment
Returns:
A feature implementation object, or null if the feature is not supported by the current environment
static getFeatureMap ()
This method retrieves a map object containing the names of available implementations for each registered feature. The map has the following structure:
		{
		featureA: [featureImplNameA1, featureImplNameA2, ...],
		featureB: [featureImplNameB1, ...]
		...
}
Returns:
A map object listing registered feature implmentations
static getLoadedMap ()
This method retrieves a map of the names of fully loaded implementations for each registered feature. The returned map has the following structure:
		{
		featureA: [featureImplNameA1, featureImplNameA2, ...],
		featureB: [featureImplNameB1, ...]
		...
		}
Returns:
A map object listing loaded implementations of registered features
static isLoaded (featureName, featureImplName) : Boolean
This method checks whether a certain feature implementation has been successfully loaded. The method returns true if the queried implementation has been successfully loaded (i.e. transmitted AND evaluated). The method throws an exception when either the feature or the implementation is unknown.
Parameters:
{Object} featureName The name of the feature to check
{Object} featureImplName - the name of the implementation of the feature to check
Returns:
{Boolean} true if the feature has been fully loaded, false otherwise
static load (requested, [onSuccess, [onError, [doc, [sync]]]])
This method loads a set of features specified by the caller. The caller can provide optional callbacks to be invoked on success and on error and also a target document to which the respective script tags should be appended. The caller specifies the features to load in a hash object, where the keys represent the feature names and the values provide the implementation parameters, for example:
nokia.Features.load({
	"map": "auto",
	"search": "auto"
}); 
Parameters:
{Object} requested A hash containing the names of the features to load (as keys) and feature implementation parameters (as values)
{function ()} [onSuccess]: A function to be called on success
{function (e)} [onError]: A function to be called on error
{Document} [doc]: document The host document
{Boolean} [sync]: A Booleand indicating whether synchronous loading via document.write is to be enforced (true) or not (false)
Documentation generated on Wed Jun 27 2012 16:54:29 GMT+0200 (CEST).