| Package | com.afcomponents.umap.providers |
| Class | public class XMLProvider |
| Inheritance | XMLProvider DefaultProvider flash.events.EventDispatcher |
| Implements | IProvider |
| Subclasses | ArcGISMapProvider, MicrosoftProvider, OpenStreetProvider, YahooProvider, ZoomifyProvider |
This class also provides a mechanism for sequental loading of the settings file, language file and copyrights. Here is the loading algorythm:
settingsURL property.parseSettings() method is invoked with the data that has been loaded.parseSettings() method is invoked with data
which getDefaultSettings() method returns.languageURL property.
In the source url, wildcard [lang] will be substituted by 2 letter language ISO code.parseLanguage() method is invoked with the data that has been loaded.parseLanguage() method is invoked with data
which getDefaultLanguage() method returns.ProviderEvent.COMPLETE event.During map functioning copyright information should be updated.
loadCopyright() method with current map center, map bounds and zoom level.
Provider, in turn, applies these values to a copyrightURL() and performes URL request.parseCopyright() method is invoked with the
successfully loaded dataparseCopyright() method is invoked with data
which getDefaultCopyright() method returns.Provider should dispatch
ControlEvent.COPYRIGHT_CHANGED with the copyright information.
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
| Property | Defined 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 | ||
![]() | logo : DisplayObject
Returns a display object with the provider's logo.
| DefaultProvider | |
![]() | mapTypes : 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 | ||
| Property | Defined by | ||
|---|---|---|---|
| _copyright : URLRequest
Copyright URL.
| XMLProvider | ||
![]() | _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 | ||
![]() | _logo : DisplayObject
Display object which containes the provider logo.
| DefaultProvider | |
![]() | _logoURL : URLRequest
URI of the provider logo.
| DefaultProvider | |
![]() | _mapTypes : Array
Array of map types.
| DefaultProvider | |
| _settings : URLRequest
Settings URL.
| XMLProvider | ||
| Method | Defined by | ||
|---|---|---|---|
|
XMLProvider(defaultData:Boolean = false, settings:* = null, language:* = null, copyright:* = null)
Creates new
XMLProvider object. | XMLProvider | ||
![]() |
addMapType(type:IMapType):Boolean
Adds new map type to the map types Array.
| DefaultProvider | |
![]() |
clearLogo():void
Clears the logo.
| DefaultProvider | |
|
dispose():void
Frees the resources accuired by the Provider.
| XMLProvider | ||
|
getDefaultCopyright():String
Returns default copyright string.
| XMLProvider | ||
|
getDefaultCopyrightURL():URLRequest
Abstract function.
| XMLProvider | ||
|
getDefaultLanguage():String
Abstract function.
| XMLProvider | ||
|
getDefaultLanguageURL():URLRequest
Abstract function.
| XMLProvider | ||
|
getDefaultSettings():String
Abstract function.
| XMLProvider | ||
|
getDefaultSettingsURL():URLRequest
Abstract function.
| XMLProvider | ||
![]() |
getMapTypeByName(mapTypeName:String):IMapType
Returns map type reference by it's name.
| DefaultProvider | |
|
Initializes the provider and starts the loading process.
| XMLProvider | ||
|
Loads copyright information for the specified area from the url defined by the
copyrightURL property. | XMLProvider | ||
![]() |
setLogo(logo:*):void
Setups the logo for the provider, loads it if necessary.
| DefaultProvider | |
| Method | Defined by | ||
|---|---|---|---|
![]() |
Queries specified map type for copyright string and generates COPYRIGHT_CHANGED event.
| DefaultProvider | |
![]() |
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 | ||
| Constant | Defined 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 | ||
| _copyright | property |
protected var _copyright:URLRequestCopyright URL.
| copyrightURL | property |
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
| _default | property |
protected var _default:BooleanFlag that, indicates whether to use default language & settings data without loading it from the server.
| DEFAULT_MAPTYPE_CLASS | property |
public static var DEFAULT_MAPTYPE_CLASS:ClassDefines 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_CLASS | property |
public static var DEFAULT_TILELAYER_CLASS:ClassDefines the class that will be used by settings parser to create new tile layer.
The default value is com.afcomponents.umap.providers::TileLayer.
| _language | property |
protected var _language:URLRequestLanguage URL.
| languageURL | property |
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
| _loader | property |
protected var _loader:URLLoader
Reference to the URLLoader object that is used for loading data.
| loadingState | property |
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. public function get loadingState():String
| _settings | property |
protected var _settings:URLRequestSettings URL.
| settingsURL | property |
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
| 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.
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.
|
| dispose | () | method |
public override function dispose():voidFrees the resources accuired by the Provider.
| getDefaultCopyright | () | method |
public override function getDefaultCopyright():StringReturns default copyright string.
ReturnsString |
| getDefaultCopyrightURL | () | method |
public function getDefaultCopyrightURL():URLRequestAbstract function. Returns default copyright URL Request object.
ReturnsURLRequest |
| getDefaultLanguage | () | method |
public function getDefaultLanguage():StringAbstract function. Returns default language data for the Provider to parse.
ReturnsString |
| getDefaultLanguageURL | () | method |
public function getDefaultLanguageURL():URLRequestAbstract function. Returns default language URL Request object.
ReturnsURLRequest |
| getDefaultSettings | () | method |
public function getDefaultSettings():StringAbstract function. Returns default settings data for the Provider to parse.
ReturnsString |
| getDefaultSettingsURL | () | method |
public function getDefaultSettingsURL():URLRequestAbstract function. Returns default settings URL Request object.
ReturnsURLRequest |
| init | () | method |
public override function init(core:UMap):voidInitializes the provider and starts the loading process.
Parameterscore: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.
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):voidLoads the queued copyright request. If the parameter is specified, overwrites the queued request.
Parametersurl: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.
data:String — Textual data that needs to be parsed.
|
| parseLanguage | () | method |
protected function parseLanguage(data:String):BooleanAbstract method. Override it for language data parser.
Parametersdata:String — Textual data that needs to be parsed.
|
Boolean — A value of true if parsing was successfull; false if it was not.
|
| parseSettings | () | method |
protected function parseSettings(data:String):BooleanParses 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.
|
Boolean — A value of true if parsing was successfull; false if it was not.
|
<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>| LOADING_COPYRIGHT | constant |
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_IDLE | constant |
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_LANGUAGE | constant |
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_SETTINGS | constant |
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.