Packagecom.afcomponents.umap.providers
Classpublic class XMLProvider
InheritanceXMLProvider Inheritance DefaultProvider Inheritance flash.events.EventDispatcher
ImplementsIProvider
SubclassesArcGISMapProvider, MicrosoftProvider, OpenStreetProvider, YahooProvider, ZoomifyProvider

Base class that provides mechanism to load provider settings via XML file. You can subclass it and override some of its methods for a custom provider.

This class also provides a mechanism for sequental loading of the settings file, language file and copyrights. Here is the loading algorythm:

During map functioning copyright information should be updated.

Another important purpose of Provider is to hold an array of map types. Methods for adding new map types, searching for map type by name and getting map type array reference are included in this class. Custom provider only needs to define at least one map type before it dispatches ProviderEvent.COMPLETE event.

Here is the complete list of methods you may want to override for you custom provider:

  • public function getDefaultSettingsURL():URLRequest - Returns default settings url.
  • public function getDefaultLanguageURL():URLRequest - Returns default language url.
  • public function getDefaultCopyrightURL():URLRequest - Returns default copyright url.
  • public function getDefaultSettings():String - Returns default settings data.
  • public function getDefaultLanguage():String - Returns default language data.
  • public function getDefaultCopyright():String - Returns default copyright data.
  • protected function parseSettings(data:String):void - Parse settings data to create map types.
  • protected function parseLanguage(data:String):void - Parse language data to load localized strings.
  • protected function parseCopyright(data:String):void - Parse copyright and dispatch ControlEvent.COPYRIGHT_CHANGED event with new copyright information.
  • public function get logo():DisplayObject - Returns a display object which containg provider logo. It will be attached to copyright control.
  • See also

    com.afcomponents.umap.events.ProviderEvent
    com.afcomponents.umap.events.ControlEvent


    Public Properties
     PropertyDefined by
      copyrightURL : URLRequest
    Gets or sets the URL Request object that will be used to download copyright data.
    XMLProvider
      DEFAULT_MAPTYPE_CLASS : Class
    [static] Defines the class that will be used by settings parser to create new map type.
    XMLProvider
      DEFAULT_TILELAYER_CLASS : Class
    [static] Defines the class that will be used by settings parser to create new tile layer.
    XMLProvider
      languageURL : URLRequest
    Gets or sets the URL Request object that will be used to download language data.
    XMLProvider
      loadingState : String
    [read-only] Indicates current loading state.
    XMLProvider
     Inheritedlogo : DisplayObject
    Returns a display object with the provider's logo.
    DefaultProvider
     InheritedmapTypes : Array
    Array which holds map types supported by this Provider.
    DefaultProvider
      settingsURL : URLRequest
    Gets or sets the URL Request object that will be used to download settings data.
    XMLProvider
    Protected Properties
     PropertyDefined by
      _copyright : URLRequest
    Copyright URL.
    XMLProvider
     Inherited_core : UMap
    Reference to the core UMap class.
    DefaultProvider
      _default : Boolean
    Flag that, indicates whether to use default language & settings data without loading it from the server.
    XMLProvider
      _language : URLRequest
    Language URL.
    XMLProvider
      _loader : URLLoader
    Reference to the URLLoader object that is used for loading data.
    XMLProvider
     Inherited_logo : DisplayObject
    Display object which containes the provider logo.
    DefaultProvider
     Inherited_logoURL : URLRequest
    URI of the provider logo.
    DefaultProvider
     Inherited_mapTypes : Array
    Array of map types.
    DefaultProvider
      _settings : URLRequest
    Settings URL.
    XMLProvider
    Public Methods
     MethodDefined by
      
    XMLProvider(defaultData:Boolean = false, settings:* = null, language:* = null, copyright:* = null)
    Creates new XMLProvider object.
    XMLProvider
     Inherited
    addMapType(type:IMapType):Boolean
    Adds new map type to the map types Array.
    DefaultProvider
     Inherited
    clearLogo():void
    Clears the logo.
    DefaultProvider
      
    dispose():void
    Frees the resources accuired by the Provider.
    XMLProvider
      
    Returns default copyright string.
    XMLProvider
      
    Abstract function.
    XMLProvider
      
    Abstract function.
    XMLProvider
      
    getDefaultLanguageURL():URLRequest
    Abstract function.
    XMLProvider
      
    Abstract function.
    XMLProvider
      
    getDefaultSettingsURL():URLRequest
    Abstract function.
    XMLProvider
     Inherited
    getMapTypeByName(mapTypeName:String):IMapType
    Returns map type reference by it's name.
    DefaultProvider
      
    init(core:UMap):void
    Initializes the provider and starts the loading process.
    XMLProvider
      
    loadCopyright(center:LatLng, bounds:LatLngBounds, zoom:Number, event:String = ""):void
    Loads copyright information for the specified area from the url defined by the copyrightURL property.
    XMLProvider
     Inherited
    setLogo(logo:*):void
    Setups the logo for the provider, loads it if necessary.
    DefaultProvider
    Protected Methods
     MethodDefined by
     Inherited
    getMapTypeCopyright(bounds:LatLngBounds, zoom:Number, mapType:IMapType = null):void
    Queries specified map type for copyright string and generates COPYRIGHT_CHANGED event.
    DefaultProvider
     Inherited
    initMapTypes():void
    Override this function to define map types.
    DefaultProvider
      
    loadNextCopyright(url:URLRequest = null):void
    Loads the queued copyright request.
    XMLProvider
      
    parseCopyright(data:String):void
    Abstract method.
    XMLProvider
      
    parseLanguage(data:String):Boolean
    Abstract method.
    XMLProvider
      
    parseSettings(data:String):Boolean
    Parses the XML data with the provider settings.
    XMLProvider
    Public Constants
     ConstantDefined by
      LOADING_COPYRIGHT : String = "loadingCopyright"
    [static] The Provider.LOADING_COPYRIGHT constant defines the value of the loadingState property of the Provider object that indicates that copyright information is being loaded at the moment.
    XMLProvider
      LOADING_IDLE : String = "loadingIdle"
    [static] The Provider.LOADING_IDLE constant defines the value of the loadingState property of the Provider object that indicates that no loading occurs at the moment.
    XMLProvider
      LOADING_LANGUAGE : String = "loadingLanguage"
    [static] The Provider.LOADING_LANGUAGE constant defines the value of the loadingState property of the Provider object that indicates that language file is being loaded at the moment.
    XMLProvider
      LOADING_SETTINGS : String = "loadingSettings"
    [static] The Provider.LOADING_SETTINGS constant defines the value of the loadingState property of the Provider object that indicates that settings file is being loaded at the moment.
    XMLProvider
    Property detail
    _copyrightproperty
    protected var _copyright:URLRequest

    Copyright URL.

    copyrightURLproperty 
    copyrightURL:URLRequest  [read-write]

    Gets or sets the URL Request object that will be used to download copyright data.

    Implementation
        public function get copyrightURL():URLRequest
        public function set copyrightURL(value:URLRequest):void
    _defaultproperty 
    protected var _default:Boolean

    Flag that, indicates whether to use default language & settings data without loading it from the server.

    DEFAULT_MAPTYPE_CLASSproperty 
    public static var DEFAULT_MAPTYPE_CLASS:Class

    Defines the class that will be used by settings parser to create new map type.

    The default value is com.afcomponents.umap.providers::MapType.

    DEFAULT_TILELAYER_CLASSproperty 
    public static var DEFAULT_TILELAYER_CLASS:Class

    Defines the class that will be used by settings parser to create new tile layer.

    The default value is com.afcomponents.umap.providers::TileLayer.

    _languageproperty 
    protected var _language:URLRequest

    Language URL.

    languageURLproperty 
    languageURL:URLRequest  [read-write]

    Gets or sets the URL Request object that will be used to download language data.

    Implementation
        public function get languageURL():URLRequest
        public function set languageURL(value:URLRequest):void
    _loaderproperty 
    protected var _loader:URLLoader

    Reference to the URLLoader object that is used for loading data.

    loadingStateproperty 
    loadingState:String  [read-only]

    Indicates current loading state.

    Can be one of the following:

  • Provider.LOADING_IDLE - Idle state, no loading occurs.
  • Provider.LOADING_SETTINGS - Loading settings file.
  • Provider.LOADING_LANGUAGE - Loading language file.
  • Provider.LOADING_COPYRIGHT - Loading copyright information.
  • Implementation
        public function get loadingState():String
    _settingsproperty 
    protected var _settings:URLRequest

    Settings URL.

    settingsURLproperty 
    settingsURL:URLRequest  [read-write]

    Gets or sets the URL Request object that will be used to download settings data.

    Implementation
        public function get settingsURL():URLRequest
        public function set settingsURL(value:URLRequest):void
    Constructor detail
    XMLProvider()constructor
    public function XMLProvider(defaultData:Boolean = false, settings:* = null, language:* = null, copyright:* = null)

    Creates new XMLProvider object.

    You should never use this class directly, instead use subclassing. You can specify URLRequest objects which will be used instead of the default ones.

    Parameters
    defaultData:Boolean (default = false) — Flag that forces provider to use default settings & language data without loading anything.
     
    settings:* (default = null) — Custom URLRequest or URL String which defines the path to the settings data.
     
    language:* (default = null) — Custom URLRequest or URL String which defines the path to the language data.
     
    copyright:* (default = null) — Custom URLRequest or URL String which defines the path to the copyright data.
    Method detail
    dispose()method
    public override function dispose():void

    Frees the resources accuired by the Provider.

    getDefaultCopyright()method 
    public override function getDefaultCopyright():String

    Returns default copyright string.

    Returns
    String
    getDefaultCopyrightURL()method 
    public function getDefaultCopyrightURL():URLRequest

    Abstract function. Returns default copyright URL Request object.

    Returns
    URLRequest
    getDefaultLanguage()method 
    public function getDefaultLanguage():String

    Abstract function. Returns default language data for the Provider to parse.

    Returns
    String
    getDefaultLanguageURL()method 
    public function getDefaultLanguageURL():URLRequest

    Abstract function. Returns default language URL Request object.

    Returns
    URLRequest
    getDefaultSettings()method 
    public function getDefaultSettings():String

    Abstract function. Returns default settings data for the Provider to parse.

    Returns
    String
    getDefaultSettingsURL()method 
    public function getDefaultSettingsURL():URLRequest

    Abstract function. Returns default settings URL Request object.

    Returns
    URLRequest
    init()method 
    public override function init(core:UMap):void

    Initializes the provider and starts the loading process.

    Parameters
    core:UMap — Reference to the core object.
    loadCopyright()method 
    public override function loadCopyright(center:LatLng, bounds:LatLngBounds, zoom:Number, event:String = ""):void

    Loads copyright information for the specified area from the url defined by the copyrightURL property. If copyright url is undefined, copyights are taken form the current map type's getCopyrights() call.

    Please note that the copyright will not be loaded right away, instead it will be queued until the loader thread has finished loading the previous request. If a new request will be recieved before the queued request has started loading, only the newest request will be queued, and the older one will be discarded.

    This method has a default implemetation: it just adds all the properties to the url and loads it. The properties include: map center, bounds if the map view, zoom level and map event. Map event can be one of the following constants, or an empty string:

  • DisplayEvent.UPDATE_POSITION: dispatched when map view has been updated.
  • DisplayEvent.UPDATE_ZOOM: dispatched when map zoom has been updated.
  • DisplayEvent.UPDATE_MAP_TYPE: dispatched when map type has been updated.
  • Here is the template url (properties are in the square brackets):

    [copyrightURL]?bounds=[bounds.width],[bounds.height]¢er=[lat],[lng]&zoom=[zoom]&event=[event]

    After URL Request object is ready it should be loaded with loadNextCopyright(request) method.

    Parameters
    center:LatLng — The coordinates of the map center.
     
    bounds:LatLngBounds — The bounds of the map view.
     
    zoom:Number — Current map zoom level.
     
    event:String (default = "") — Indicates the map event.
    loadNextCopyright()method 
    protected function loadNextCopyright(url:URLRequest = null):void

    Loads the queued copyright request. If the parameter is specified, overwrites the queued request.

    Parameters
    url:URLRequest (default = null) — URL reqeust that should be put in the queue or loaded if the loader is free. If omitted, loader will process previously queued request or do nothing if queue is empty.
    parseCopyright()method 
    protected function parseCopyright(data:String):void

    Abstract method. Override it for custom copyright data parser. Don't forget to dispatch ControlEvent.COPYRIGHT_CHANGED event with the new copyright information.

    Parameters
    data:String — Textual data that needs to be parsed.
    parseLanguage()method 
    protected function parseLanguage(data:String):Boolean

    Abstract method. Override it for language data parser.

    Parameters
    data:String — Textual data that needs to be parsed.

    Returns
    Boolean — A value of true if parsing was successfull; false if it was not.
    parseSettings()method 
    protected function parseSettings(data:String):Boolean

    Parses the XML data with the provider settings. Override it for custom settings data parser.

    This method has a default implementation. It will define map types out of a XML data. Parameters

    data:String — Textual data that needs to be parsed.

    Returns
    Boolean — A value of true if parsing was successfull; false if it was not.

    Example
    Here is a valid XML structure (nodes in bold are required):
          <UMapProvider>
              <logo>http://myserver.com/provider_logo.png</logo>                       <!-- Provider logo -->
                  <mapType>
                      <!-- Define new map type -->
                      <name>myMapType</name>                                           <!-- Map type name -->
                      <caption>My Map Type</caption>                                   <!-- Map type caption -->
                      <errorMessage>No tile.</errorMessage>                            <!-- Error message if tile is unavailable -->
                      <copyrightMessage>\x26#169;2008 - MyCompany Ltd.</copyrightMessage>    <!-- Default copyright message -->
                      <textColor>0x000000</textColor>                                  <!-- RGB color of the copyright string -->
                      <linkColor>0x7777CC</linkColor>                                  <!-- RGB color of the terms of use link -->
                      <layer>
                          <!-- Define new tile layer -->
                          <url><![CDATA[[server]/[version]/x[x]_y[y]_zoom[z].png]]></url>     <!-- Tile image URL (with wildcards) -->
                          <maxZoom>18</maxZoom>                                        <!-- Maximum zoom level -->
                          <type>com.afcomponents.umap.providers::TileLayer</type>        <!-- TileLayer class -->
                          <alpha>1.0</alpha>                                           <!-- Layer opacity [0..1] -->
                          <minZoom>1</minZoom>                                         <!-- Minimum zoom level -->
                          <noError>false</noError>                                     <!-- Display error message? -->
                          <version>ap.60</version>                                     <!-- Value for [version] wildcard -->
                          <servers>
                              <!-- Define one or more tile servers -->
                              <url>http://myserver.com/tiles</url>                     <!-- Server URL -->
                              <!-- more urls here -->
                          </servers>
                      </layer>
                      <!-- more layers here -->
                  </mapType>
                  <!-- more map types here -->
          </UmapProvider>

    Constant detail
    LOADING_COPYRIGHTconstant
    public static const LOADING_COPYRIGHT:String = "loadingCopyright"

    The Provider.LOADING_COPYRIGHT constant defines the value of the loadingState property of the Provider object that indicates that copyright information is being loaded at the moment.

    LOADING_IDLEconstant 
    public static const LOADING_IDLE:String = "loadingIdle"

    The Provider.LOADING_IDLE constant defines the value of the loadingState property of the Provider object that indicates that no loading occurs at the moment.

    LOADING_LANGUAGEconstant 
    public static const LOADING_LANGUAGE:String = "loadingLanguage"

    The Provider.LOADING_LANGUAGE constant defines the value of the loadingState property of the Provider object that indicates that language file is being loaded at the moment.

    LOADING_SETTINGSconstant 
    public static const LOADING_SETTINGS:String = "loadingSettings"

    The Provider.LOADING_SETTINGS constant defines the value of the loadingState property of the Provider object that indicates that settings file is being loaded at the moment.