<?xml version="1.0" encoding="utf-8"?>
<s:VGroup xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
paddingTop="20" paddingLeft="20" paddingRight="20">
<fx:Script>
import flash.sensors.Geolocation;
protected var g:Geolocation;
</fx:Script>
<s:creationComplete>
if (Geolocation.isSupported)
{
g = new Geolocation();
if (g.muted)
{
l.text = "Access to GPS has been denied";
return;
}
l.text = "Locating...";
g.addEventListener(GeolocationEvent.UPDATE, function(event:GeolocationEvent):void {
l.text = "latitude = " + event.latitude +
"\nlongitude = " + event.longitude +
"\naltitude = " + event.altitude +
"\nverticalAccuracy = " + event.verticalAccuracy +
"\nhorizontalAccuracy = " + event.horizontalAccuracy +
"\nspeed = " + event.speed +
"\nheading = " + event.heading +
"\ntimestamp = " + event.timestamp;
}, false, 0, true);
}
else
{
l.text = "Geolocation is not supported on this device";
}
</s:creationComplete>
<s:removedFromStage>
g = null;
</s:removedFromStage>
<s:Label id="l"/>
</s:VGroup>