Packageardisia.components.htmlGeolocation
Classpublic class HtmlGeolocation
InheritanceHtmlGeolocation Inheritance flash.events.EventDispatcher

Class that uses the browser's HTML5 API to retrieve the user's geographic location. Flash has both Geolocation and GeolocationEvent classes for mobile devices with location sensors. This class brings some of that functionality to desktop based applications.

This component will NOT work within the AIR environment. For HTML support in AIR, try the native mx.controls.HTML and flash.html.HTMLLoader classes.

Only works if the browser supports HTML5 geolocation and ExternalInterface.

To use: initialize this class in the declarations tag or in actionscript, attach an UPDATE and ERROR listener and call getCurrentPosition(). Since the location data is returned asynchronously, an event handler is required to get the location data instead of directly returning the position information by the getCurrentPosition function.

View the technical documentation on the Ardisia Labs website for more information.

Design Notes:



Public Properties
 PropertyDefined By
  isSupported : Boolean
[read-only] Return whether the ExternalInterface supports the HTML5 geolocation api.
HtmlGeolocation
Public Methods
 MethodDefined By
  
HtmlGeolocation
  
Get the current geolocation position via the HTML5 Geolocation API.
HtmlGeolocation
Protected Methods
 MethodDefined By
  
Adds the code necessary to locate the swf in the html DOM.
HtmlGeolocation
  
geoLocationError(error:Object):void
Called by the browser after getCurrentPosition() fails and returns an error.
HtmlGeolocation
  
geoLocationPositionResults(position:Object):void
Called by the browser after getCurrentPosition() successfully returns positioning data.
HtmlGeolocation
  
isTestId(testString:String):Boolean
Tests whether the passed string is the test string.
HtmlGeolocation
Events
 Event Summary Defined By
  Dispatched when the ExternalInterface returns an error after a call to getCurrentPosition().HtmlGeolocation
  Dispatched when the ExternalInterface returns position data after a call to getCurrentPosition().HtmlGeolocation
Property Detail
isSupportedproperty
isSupported:Boolean  [read-only]

Return whether the ExternalInterface supports the HTML5 geolocation api.

The default value is undefined.


Implementation
    public function get isSupported():Boolean
Constructor Detail
HtmlGeolocation()Constructor
public function HtmlGeolocation()



Method Detail
addEmbeddedReference()method
protected function addEmbeddedReference():void

Adds the code necessary to locate the swf in the html DOM.

geoLocationError()method 
protected function geoLocationError(error:Object):void

Called by the browser after getCurrentPosition() fails and returns an error.

Dispatches the GeolocationErrorEvent event.

Parameters

error:Object — the error Object returned by html

geoLocationPositionResults()method 
protected function geoLocationPositionResults(position:Object):void

Called by the browser after getCurrentPosition() successfully returns positioning data.

Dispatches the HtmlGeolocationEvent.UPDATE event with the position data attached. Returns the same data as the flash GeolocationEvent for mobile devices.

Parameters

position:Object — Object the geo data returned by the browser

getCurrentPosition()method 
public function getCurrentPosition():void

Get the current geolocation position via the HTML5 Geolocation API.

isTestId()method 
protected function isTestId(testString:String):Boolean

Tests whether the passed string is the test string.

Parameters

testString:String

Returns
Boolean — true on success
Event Detail
error Event
Event Object Type: ardisia.components.htmlGeolocation.events.HtmlGeolocationErrorEvent
HtmlGeolocationErrorEvent.type property = ardisiaFlexElements.components.geolocation.events.GeolocationErrorEvent

Dispatched when the ExternalInterface returns an error after a call to getCurrentPosition().

update Event  
Event Object Type: ardisia.components.htmlGeolocation.events.HtmlGeolocationEvent
HtmlGeolocationEvent.type property = ardisiaFlexElements.components.geolocation.events.GeolocationDesktopEvent

Dispatched when the ExternalInterface returns position data after a call to getCurrentPosition().