<?xml version="1.0" encoding="utf-8"?>
<s:Module xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
xmlns:containers="containers.*"
xmlns:data="containers.data.*"
xmlns:separators="ardisia.components.separators.*"
xmlns:htmlGeolocation="ardisia.components.htmlGeolocation.*"
frameRate="60"
width="100%" height="100%"
removedFromStage="removedFromStageHandler(event)"
preinitialize="application1_preinitializeHandler(event)">
<fx:Script>
<![CDATA[
import flash.net.navigateToURL;
import mx.events.FlexEvent;
import spark.components.Alert;
import ardisia.components.htmlGeolocation.events.HtmlGeolocationEvent;
public function creationComplete():void
{
}
protected function geolocation_updateHandler(event:HtmlGeolocationEvent):void
{
latSelect.text = String(event.latitude);
longSelect.text = String(event.longitude);
timeSelect.text = String(event.timestamp);
accuracySelect.text = String(event.accuracy);
altitudeSelect.text = String(event.altitude);
altitudeAccuracySelect.text = String(event.altitudeAccuracy);
headingSelect.text = String(event.heading);
speedSelect.text = String(event.speed);
openMapSelect.enabled = !isNaN(event.latitude) && !isNaN(event.longitude);
}
protected function button1_clickHandler(event:MouseEvent):void
{
var url:String = "https://maps.google.com/maps?q=" + Number(latSelect.text) + "+" + Number(longSelect.text);
navigateToURL(new URLRequest(url), "_blank");
}
protected function application1_preinitializeHandler(event:FlexEvent):void
{
Security.allowDomain("*");
}
protected function removedFromStageHandler(event:Event):void
{
}
]]>
</fx:Script>
<fx:Declarations>
<htmlGeolocation:HtmlGeolocation id="htmlGeolocation"
error="Alert.show(event.errorType, 'ERROR', 4, this, null, null, 0, moduleFactory);"
update="geolocation_updateHandler(event)" />
</fx:Declarations>
<s:states>
<s:State name="stockholm" />
<s:State name="london" />
<s:State name="spark" />
</s:states>
<containers:DemoApplicationWrapper id="demoAppWrapper"
width="100%" height="100%"
westRegionTitle="HtmlGeolocation Description"
description="Component 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. Only works if the browser supports HTML5 geolocation and ExternalInterface."
currentState.stockholm="stockholm" currentState.london="london" currentState.spark="spark">
<containers:expandingContainerContent>
<!--- expanding container #1 -->
<data:ExpandingContainerData>
<data:label>ExternalInterface</data:label>
<data:content>
<s:FormItem label="Supported:">
<s:Label paddingTop="5"
text="{ExternalInterface.available}"/>
<s:helpContent>
<s:Image source="@Embed(source='icons/question.png')"
toolTip="True if your browser supports the NPRuntime API, which enables Flash's ExternalInterface's API. Required to use this component."/>
</s:helpContent>
</s:FormItem>
</data:content>
</data:ExpandingContainerData>
</containers:expandingContainerContent>
<containers:centerContent>
<!--- example #1 -->
<data:PrimaryContentData>
<data:tabLabel>Example</data:tabLabel>
<data:exampleDescription>If the HTML5 geolocation API is supported by your browser, click the 'Retrieve Location' button below to display your geolocation data. Many browsers will ask for permission before sending geolocation data. Regarding privacy, this application does not record any geolocation calls made.</data:exampleDescription>
<data:toolbarContent>
<s:Button label="Retrieve Location"
click="htmlGeolocation.getCurrentPosition();"/>
</data:toolbarContent>
<data:primaryContent>
<s:BorderContainer horizontalCenter="0" verticalCenter="0">
<s:Form top="20" right="20" bottom="20" left="20">
<s:FormHeading label="Your Location via the HtmlGeolocation Component:" />
<s:FormItem label="Latitude:">
<s:Label id="latSelect" />
</s:FormItem>
<s:FormItem label="Longitude:">
<s:Label id="longSelect" />
</s:FormItem>
<s:FormItem label="Time:">
<s:Label id="timeSelect" />
</s:FormItem>
<s:FormItem label="Accuracy:">
<s:Label id="accuracySelect" />
</s:FormItem>
<s:FormItem label="Altitude:">
<s:Label id="altitudeSelect" />
</s:FormItem>
<s:FormItem label="Altitude Accuracy:">
<s:Label id="altitudeAccuracySelect" />
</s:FormItem>
<s:FormItem label="Heading:">
<s:Label id="headingSelect" />
</s:FormItem>
<s:FormItem label="Speed:">
<s:Label id="speedSelect" />
</s:FormItem>
<separators:HSeparator width="100%"/>
<s:Button id="openMapSelect"
enabled="false"
label="Open Location In Google Maps"
click="button1_clickHandler(event)" />
</s:Form>
</s:BorderContainer>
</data:primaryContent>
</data:PrimaryContentData>
</containers:centerContent>
</containers:DemoApplicationWrapper>
</s:Module>