Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ryan Stewart
committed
Feb 21, 2010
1 parent
c0991de
commit 426a1ff
Showing
8 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
This project takes GPX files and parses them into ActionScript objects. | ||
|
||
Created by Ryan Stewart and Simeon Bateman. | ||
|
||
Source is in the src directory and an example use case is in the examples directory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<actionScriptProperties mainApplicationPath="Main.mxml" projectUUID="390797cf-e926-478a-a000-25a942b518cc" version="6"> | ||
<compiler additionalCompilerArguments="-locale en_US" autoRSLOrdering="true" copyDependentFiles="true" fteInMXComponents="false" generateAccessible="true" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin-debug" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="true" useDebugRSLSwfs="true" verifyDigests="true" warn="true"> | ||
<compilerSourcePath/> | ||
<libraryPath defaultLinkType="0"> | ||
<libraryPathEntry kind="4" path=""> | ||
<excludedEntries> | ||
<libraryPathEntry kind="3" linkType="1" path="${PROJECT_FRAMEWORKS}/libs/flex.swc" useDefaultLinkType="false"/> | ||
</excludedEntries> | ||
</libraryPathEntry> | ||
<libraryPathEntry kind="1" linkType="1" path="libs"/> | ||
<libraryPathEntry kind="3" linkType="1" path="/gpxas3/bin/gpxas3.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="/Library/Devlib/as3corelib/bin/as3corelib.swc" useDefaultLinkType="false"/> | ||
<libraryPathEntry kind="3" linkType="1" path="/Library/SDKs/com.google.maps/lib/map_flex_1_17.swc" useDefaultLinkType="false"/> | ||
</libraryPath> | ||
<sourceAttachmentPath/> | ||
</compiler> | ||
<applications> | ||
<application path="Main.mxml"> | ||
<airExcludes/> | ||
</application> | ||
</applications> | ||
<modules/> | ||
<buildCSSFiles/> | ||
</actionScriptProperties> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="no"?> | ||
<flexProperties enableServiceManager="false" flexServerFeatures="0" flexServerType="0" toolCompile="true" useServerFlexSDK="false" version="2"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>GpxAS3 Example</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.adobe.flexbuilder.project.flexbuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>com.adobe.flexbuilder.project.apollobuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.adobe.flexbuilder.project.apollonature</nature> | ||
<nature>com.adobe.flexbuilder.project.flexnature</nature> | ||
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature> | ||
</natures> | ||
</projectDescription> |
3 changes: 3 additions & 0 deletions
3
examples/GpxAS3 Example/.settings/org.eclipse.core.resources.prefs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#Sat Feb 20 20:54:35 PST 2010 | ||
eclipse.preferences.version=1 | ||
encoding/<project>=utf-8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
<?xml version="1.0" encoding="utf-8" standalone="no"?> | ||
<application xmlns="http://ns.adobe.com/air/application/1.5.3"> | ||
|
||
<!-- Adobe AIR Application Descriptor File Template. | ||
Specifies parameters for identifying, installing, and launching AIR applications. | ||
xmlns - The Adobe AIR namespace: http://ns.adobe.com/air/application/1.5.3 | ||
The last segment of the namespace specifies the version | ||
of the AIR runtime required for this application to run. | ||
minimumPatchLevel - The minimum patch level of the AIR runtime required to run | ||
the application. Optional. | ||
--> | ||
|
||
<!-- The application identifier string, unique to this application. Required. --> | ||
<id>Main</id> | ||
|
||
<!-- Used as the filename for the application. Required. --> | ||
<filename>Main</filename> | ||
|
||
<!-- The name that is displayed in the AIR application installer. | ||
May have multiple values for each language. See samples or xsd schema file. Optional. --> | ||
<name>Main</name> | ||
|
||
<!-- An application version designator (such as "v1", "2.5", or "Alpha 1"). Required. --> | ||
<version>v1</version> | ||
|
||
<!-- Description, displayed in the AIR application installer. | ||
May have multiple values for each language. See samples or xsd schema file. Optional. --> | ||
<!-- <description></description> --> | ||
|
||
<!-- Copyright information. Optional --> | ||
<!-- <copyright></copyright> --> | ||
|
||
<!-- Publisher ID. Used if you're updating an application created prior to 1.5.3 --> | ||
<!-- <publisherID></publisherID> --> | ||
|
||
<!-- Settings for the application's initial window. Required. --> | ||
<initialWindow> | ||
<!-- The main SWF or HTML file of the application. Required. --> | ||
<!-- Note: In Flash Builder, the SWF reference is set automatically. --> | ||
<content>[This value will be overwritten by Flash Builder in the output app.xml]</content> | ||
|
||
<!-- The title of the main window. Optional. --> | ||
<!-- <title></title> --> | ||
|
||
<!-- The type of system chrome to use (either "standard" or "none"). Optional. Default standard. --> | ||
<!-- <systemChrome></systemChrome> --> | ||
|
||
<!-- Whether the window is transparent. Only applicable when systemChrome is none. Optional. Default false. --> | ||
<!-- <transparent></transparent> --> | ||
|
||
<!-- Whether the window is initially visible. Optional. Default false. --> | ||
<!-- <visible></visible> --> | ||
|
||
<!-- Whether the user can minimize the window. Optional. Default true. --> | ||
<!-- <minimizable></minimizable> --> | ||
|
||
<!-- Whether the user can maximize the window. Optional. Default true. --> | ||
<!-- <maximizable></maximizable> --> | ||
|
||
<!-- Whether the user can resize the window. Optional. Default true. --> | ||
<!-- <resizable></resizable> --> | ||
|
||
<!-- The window's initial width. Optional. --> | ||
<!-- <width></width> --> | ||
|
||
<!-- The window's initial height. Optional. --> | ||
<!-- <height></height> --> | ||
|
||
<!-- The window's initial x position. Optional. --> | ||
<!-- <x></x> --> | ||
|
||
<!-- The window's initial y position. Optional. --> | ||
<!-- <y></y> --> | ||
|
||
<!-- The window's minimum size, specified as a width/height pair, such as "400 200". Optional. --> | ||
<!-- <minSize></minSize> --> | ||
|
||
<!-- The window's initial maximum size, specified as a width/height pair, such as "1600 1200". Optional. --> | ||
<!-- <maxSize></maxSize> --> | ||
</initialWindow> | ||
|
||
<!-- The subpath of the standard default installation location to use. Optional. --> | ||
<!-- <installFolder></installFolder> --> | ||
|
||
<!-- The subpath of the Programs menu to use. (Ignored on operating systems without a Programs menu.) Optional. --> | ||
<!-- <programMenuFolder></programMenuFolder> --> | ||
|
||
<!-- The icon the system uses for the application. For at least one resolution, | ||
specify the path to a PNG file included in the AIR package. Optional. --> | ||
<!-- <icon> | ||
<image16x16></image16x16> | ||
<image32x32></image32x32> | ||
<image48x48></image48x48> | ||
<image128x128></image128x128> | ||
</icon> --> | ||
|
||
<!-- Whether the application handles the update when a user double-clicks an update version | ||
of the AIR file (true), or the default AIR application installer handles the update (false). | ||
Optional. Default false. --> | ||
<!-- <customUpdateUI></customUpdateUI> --> | ||
|
||
<!-- Whether the application can be launched when the user clicks a link in a web browser. | ||
Optional. Default false. --> | ||
<!-- <allowBrowserInvocation></allowBrowserInvocation> --> | ||
|
||
<!-- Listing of file types for which the application can register. Optional. --> | ||
<!-- <fileTypes> --> | ||
|
||
<!-- Defines one file type. Optional. --> | ||
<!-- <fileType> --> | ||
|
||
<!-- The name that the system displays for the registered file type. Required. --> | ||
<!-- <name></name> --> | ||
|
||
<!-- The extension to register. Required. --> | ||
<!-- <extension></extension> --> | ||
|
||
<!-- The description of the file type. Optional. --> | ||
<!-- <description></description> --> | ||
|
||
<!-- The MIME content type. --> | ||
<!-- <contentType></contentType> --> | ||
|
||
<!-- The icon to display for the file type. Optional. --> | ||
<!-- <icon> | ||
<image16x16></image16x16> | ||
<image32x32></image32x32> | ||
<image48x48></image48x48> | ||
<image128x128></image128x128> | ||
</icon> --> | ||
|
||
<!-- </fileType> --> | ||
<!-- </fileTypes> --> | ||
|
||
</application> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009" | ||
xmlns:s="library://ns.adobe.com/flex/spark" | ||
xmlns:mx="library://ns.adobe.com/flex/mx" | ||
nativeDragEnter="windowedapplication1_nativeDragEnterHandler(event)" | ||
nativeDragDrop="windowedapplication1_nativeDragDropHandler(event)" | ||
xmlns:maps="com.google.maps.*"> | ||
|
||
<fx:Script> | ||
<![CDATA[ | ||
import com.adobe.gpslib.GPX; | ||
import com.adobe.gpslib.GPXService; | ||
import com.adobe.gpslib.gpx.Waypoint; | ||
import com.adobe.gpslib.gpx.events.ParseEvent; | ||
import com.google.maps.InfoWindowOptions; | ||
import com.google.maps.LatLng; | ||
import com.google.maps.MapEvent; | ||
import com.google.maps.MapMouseEvent; | ||
import com.google.maps.MapType; | ||
import com.google.maps.controls.ZoomControl; | ||
import com.google.maps.overlays.Marker; | ||
import com.google.maps.overlays.MarkerOptions; | ||
import com.google.maps.styles.FillStyle; | ||
import com.google.maps.styles.StrokeStyle; | ||
protected function windowedapplication1_nativeDragEnterHandler(event:NativeDragEvent):void | ||
{ | ||
if(event.clipboard.hasFormat(ClipboardFormats.FILE_LIST_FORMAT)) | ||
{ | ||
var arrFiles:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array; | ||
// This only supports one file, so make sure only file file is being dragged into the application | ||
if(arrFiles.length == 1) | ||
{ | ||
var file:File = File(arrFiles[0]); | ||
// Make sure that the file is a gpx file | ||
if(file.extension == "gpx") | ||
{ | ||
NativeDragManager.acceptDragDrop(this); | ||
} | ||
} | ||
} | ||
} | ||
protected function windowedapplication1_nativeDragDropHandler(event:NativeDragEvent):void | ||
{ | ||
// This is the code that handles dealing with the file when it's dropped onto the AIR app. | ||
var arrFiles:Array = event.clipboard.getData(ClipboardFormats.FILE_LIST_FORMAT) as Array; | ||
var file:File = File(arrFiles[0]); | ||
var stream:FileStream = new FileStream(); | ||
stream.open(file,FileMode.READ); | ||
var fileData:String = stream.readUTFBytes(stream.bytesAvailable); | ||
stream.close(); | ||
var xmlData:XML = new XML(fileData); | ||
/** | ||
* There are two different ways to load GPX data. | ||
* | ||
* The first is just to call the static load method and pass in XML data: | ||
* | ||
* var gpx:GPX = GPX.load(xmlData); | ||
* | ||
* | ||
* | ||
* The second is to use the service which lets you add an event listener | ||
* to the GPXService and wait until it's finished parsing the GPX file. This | ||
* can be helpful for larger files that may take time to parse. | ||
* | ||
* var gpxSrv:GPXService = new GPXService(); | ||
* gpxSrv.addEventListener(ParseEvent.PARSE_COMPLETE,onGpxParse); | ||
* gpxSrv.load(xmlData); | ||
* | ||
* | ||
* | ||
* This example uses the service method. | ||
**/ | ||
// Create a new GPXService | ||
var gpxSrv:GPXService = new GPXService(); | ||
// This event will fire when the GPX file is finished loading and parsing | ||
gpxSrv.addEventListener(ParseEvent.PARSE_COMPLETE,onGpxParse); | ||
// Call the load method on the XML data | ||
gpxSrv.load(xmlData); | ||
} | ||
protected function onGpxParse(event:ParseEvent):void | ||
{ | ||
var len:int = event.gpx.arrWaypoints.length; | ||
// This code parses through the waypoints and plots them on | ||
// the Google map. | ||
for(var i:int=0; i<len; i++) | ||
{ | ||
// Create a new Waypoint based on the array of Waypoints from the GPX file | ||
var wpt:Waypoint = event.gpx.arrWaypoints[i] as Waypoint; | ||
// Use latitude/longitude to create a new Google LatLng object | ||
var latLng:LatLng = new LatLng(wpt.latitude,wpt.longitude); | ||
// Set the marker options for the Google map marker | ||
var markerOpt:MarkerOptions = new MarkerOptions({ | ||
strokeStyle: new StrokeStyle({color: 0x987654}), | ||
fillStyle: new FillStyle({color: 0x223344, alpha: 0.8}), | ||
radius: 12, | ||
hasShadow: true | ||
}); | ||
// Create a new marker and then add it to the map | ||
var marker:Marker = new Marker(latLng); | ||
map.addOverlay(marker); | ||
} | ||
// This centers the map on the first waypoint in the GPX array | ||
var centerLatLng:LatLng = new LatLng(event.gpx.arrWaypoints[0].latitude, | ||
event.gpx.arrWaypoints[0].longitude); | ||
map.setCenter(centerLatLng); | ||
} | ||
protected function map_mapevent_mapreadyHandler(event:MapEvent):void | ||
{ | ||
// When the map is ready, change it to a Physical map and add a zoom control | ||
map.setMapType(MapType.PHYSICAL_MAP_TYPE); | ||
map.addControl(new ZoomControl()); | ||
} | ||
]]> | ||
</fx:Script> | ||
|
||
<fx:Declarations> | ||
<!-- Place non-visual elements (e.g., services, value objects) here --> | ||
</fx:Declarations> | ||
<maps:Map id="map" url="http://blog.digitalbackcountry.com" | ||
key="ABQIAAAAEPSnxMQDa8BRcDfJB7EW1hTWCdQ-AJckUnuSppzI_Y_GSzvx2xRP-k43cI98_ddac2yNC8iG9QhgOQ" | ||
width="100%" height="100%" mapevent_mapready="map_mapevent_mapreadyHandler(event)" /> | ||
</s:WindowedApplication> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
These examples are provided to show how to use the GpxAs3 library. | ||
|
||
Most of them will require the Google Maps SDK which can be found here - http://code.google.com/apis/maps/documentation/flash/ |