Return to Snippet

Revision: 53152
at November 15, 2011 04:35 by chrisaiv


Initial Code
var geo:Geolocation = new Geolocation();
 geo.addEventListener(GeolocationEvent.UPDATE, geolocationUpdateHandler);
 function geolocationUpdateHandler(e:GeolocationEvent):void
 {
     var altitude:Number = e.altitude;
     //Meters Per Second
     var mps:Number = e.speed;
     //Miles Per Hour
     var mph:Number = Math.round( (mps * 360000) / 160934.4 ) );
     trace( "altitude:", altitude, "meters per second:", mps, "miles per hour:", mph );
 }

Initial URL

                                

Initial Description
There are ways to calculate speed and altitude using the GeoLocation class.   In the US, you can even calculate Miles Per Hour.

Initial Title
AS3: Calculating MPH using GeoLocation (version 1)

Initial Tags

                                

Initial Language
ActionScript 3