| AIS Parser SDK » Demo |
|
Paste in up to 10 AIVDM or AIVDO AIS messages and click the 'Plot Ships' button to
plot the ship positions on the GoogleMap. If you do not have any AIVDM messages available
you can use these: !AIVDM,1,1,,B,15MqvC0Oh9G?qinK?VlPhA480@2n,0*1F !AIVDM,1,1,,B,15Mf@6P001G?v68K??4SejL<00Sl,0*71 !AIVDM,1,1,,B,15Mn4kPP01G?qNvK>:grkOv<0<11,0*55 !AIVDM,1,1,,B,15O1Pv0022o?GeNKB3f7QV2>00SP,0*26 !AIVDM,1,1,,B,15MqvC0Oh:G?qj0K?Vp@di4B0@5>,0*44 !AIVDM,1,1,,B,15NcRf0P3wG?Wq`K>o=RP?vB0<1J,0*7B
What is this?
How does it work? The code for this page is availble here. The basic structure of the page is taken from the Google Map API example page. I then added my own template to it, and some php code to pass the AIVDM strings to the ais_json application. After the javascript section is started we insert a little bit of PHP code to check to see if any AIVDM sentences have been passed to the script. If the 'aisdata' field (from a POST to the demo.php page) has data in it, it is passed to the AIS Parser SDK's JSON demo application. It parses the AIVDM sentences and outputs a javascript variable named ships. The first javascript code sets up the icon to use for the ship positions. We could even make a custom icon that looked like a ship. This is done by setting the icon size and graphics of the GIcon() object that we create.The first function, createMarker() is a helper function to create a marker at a position using the point (position), icon and text label passed to the function. Each marker also has a click event associated with it that will open the information window. You could easily add the Lat/Lon of the ship, its name, destination, etc. fccSearch() is an incomplete function that attempts to pass the MMSI to the FCC search form. It is currently commented out because it doesn't work. So instead it just shows a link to the FCC search form where you can paste the MMSI in manually. This function is called when building the text label to send to the createMarker() function. The load() function is where all the fun happens. load() is called when the page is loaded (because it has been set in the onload field of the body section of the page. It first creates a map, adds the basic controls to the map and sets the center of the map to the first ship in the list. It then steps through the list of ships and places markers at each position using the createMarker() function. The rest of the page contains the form, pre-populated with AIVDM messages if nothing has been entered before, and this text. Not much to it, is there? |
Copyright © 2007-2008 by Brian C. Lane
All Rights Reserved