_AIS Greece
 
Publishing AIS Data on the Internet from Shipplotter using Google Maps
   
  We will discuss here the method of publishing your AIS Data on the internet from Shipplotter using google maps and a scheduled ftp upload of an xml file which is read by a page which uses the google maps API.  
   
  This is not difficult at all and because the data is sent via ftp upload there is no need to have an advanced hosting package with possibility to use databases.  
   
  Join the Shipplotter Yahoo Group  
   
  In order to obtain the required files you will need a yahoo id because you will have to sign up for the shipplotter forum which is based out of yahoo groups. I would recommend anyway to join that group because you can get some great assistance for your AIS hobby.  
   
  Get the Required Files  
   
 
 
     
  Once you have joined you can go into the files section and go inside the VB Scripts folder.  
     
 
 
 
 
  You will need to download the vbship4.zip. Ignore that it is a testing version, everybody is using it anyway.  
     
 
 
     
  You will also need the ship6.vbs or the ship8a.zip. If you are using earlier than windows XP then you dont want the ship8a.zip because it is not working.  
     
  Setting up the Google Maps Page using vbship4.zip  
     
 
 
     
  So if we take a look inside vbship4.zip we see the above files. We are only going to use google.html. Lets edit this file by opening it in notepad.  
     
  Get a Google Maps API Key  
     
  You will need to sign up for a Google Maps API Key. Please note what they say about this.  
     
  A single Maps API key is valid for a single "directory" on your web server, so if you sign up for the URL http://www.mygooglemapssite.com/mysite, the key you get will be good for all URLs in the http://www.mygooglemapssite.com/mysite/ directory.  
     
  So say we will be putting the files into a directory called /liveais. Then we will want to get a key for http://www.youraissite.com/liveais  
     
  When you have a key, edit the google.html page in notepad and put your key where the bold part shown below is in the file, replacing the bold part with your key.  
     
  <!-- Get an API key from http://www.google.com/apis/maps/ -->
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;
key=ABQIAAAAFVb255bTSpn4DC0nkcIz3hTgmueMIh62ahlPS2dC-
 
  DIXqzci AxRZItsH3Fy4UcBpz0Q4D8XHzbxt3A" type="text/javascript"></script>  
     
  Set your map center  
     
   
     
  If you use the page with the default settings it will centre over the Isle of Man. We need to set the center of the map with your location. So find the following code in the google.html page.  
     
  map.setCenter(new GLatLng(54.08, -4.53), 8); // Change these to your own part of the world  
     
  We are going to change the bold items to your part of the world. They are in the format (Latitude, Longitude), Zoom). But you cannot just take co-ordinates from your GPS or chart which will probably be in WSG84 projection because google maps is in mercator projection. Also zoom is something specific to google maps.  
     
  The best way to go this is go to google maps. Move the map around and change the zoom level until you have the map centered how you would like the map to appear when the user first sees your website.  
     
   
     
  So say I set it like this.  
     
 
 
     
  At the top right of the map there is a "link to this page" link which we can click and then we see the above box. Right there in the top link is the numbers which you want. Copy and paste it into a blank notepad so you can get the numbers.  
     
  http://maps.google.com/?ie=UTF8&ll=37.88786,23.708496  &spn=3.142832,5.141602&z=8&om=0  
     
  So in my case I got the above link and in bold is the numbers which I want.  
     
  map.setCenter(new GLatLng(54.08, -4.53), 8); // Change these to your own part of the world  
     
  So in the google.html file I will edit the above part to be like the below one by replacing the bold numbers with the numbers I got.  
     
  map.setCenter(new GLatLng(37.88786, 23.708496), 8); // Change these to your own part of the world  
     
  So my file now has the above line and my map will look like the last map posted above when people check my page.  
     
  Upload the google.html file to your webpage  
     
  One you have set the above two parameters then your page is ready except for the customisations that you will do later to make it look like YOUR page and not the default one which all the lazy people will have.  
     
  So you can upload the page to your webspace using ftp.  
     
  So if you used the same address as in the example for getting your google maps key like http://www.youraissite.com/liveais  
     
 

You would want to make a directory in the root of your site called liveais and upload the file to that directory. Personally i would recommend to rename the google.html to index.htm so that when people access the URL http://www.youraissite.com/liveais then it will come up automatically.

 
     
  This is better than leaving it as google.html which will mean that they will have to put the full URL to the file like http://www.youraissite.com/liveais/google.html which is not so clever.  
     
  Setting up ship6.vbs or ship8a.zip  
     
  We mentioned before that ship6.vbs is the one for windows earlier than XP. This one is working fine in windows 2000. If you plan on using the more up to date one in ship8a.zip because you have installed shipplotter on XP or later then use the ship8.vbs in the ship8a.zip file.  
     
  What the vbs file does is collect all the current data from shipplotter and upload it to your site via the ftp access script included in the file. The data will be in a xml file, by default this is data.xml. For this all to be working and uploading data you will need to have a fully working shipplotter installation.  
     
  This file is referenced in the google.html file with the following line.  
     
  GDownloadUrl("data.xml?"+Math.random(), function(data, responseCode) {
var xmlDoc = GXml.parse(data);
 
     
  So if you change the name of the xml file in the vbs script then the bold part is what you will want to change in the google.html file.  
     
  So lets edit the ship6.vbs or ship8.vbs to change some parameters. Personally i would make a directory C:\vbship of your computer and put the ship6.vbs there first. Then lets edit it using notepad. We will skip some parameters just to have a basic installation.  
     
  ' ***SET the two characters of your ShipPlotter share code:
my_share = "a0"
 
     
  This above one is only in ship8.vbs. You can find your share code in shipplotter in HELP / ABOUT SHIPPLOTTER.  
     
 
 
     
 
 
     
  Then your two character share code is shown as above.  
     
  ' ***SET value to True (vs False) if the home AIS Receiver Location is to be plotted.
' If True, then set local latitude, longitude, and name:
my_show = True
 
     
  By default the file is set to plot your AIS Receiver location on the google map. If you dont want it plotted then set the bold value to False. Otherwise you will have to set your Long and Lat by changing the bold values indicated below.  
     
  my_lat = "26.000"
' ***SET home longitude:
my_lon = "-80.000"
' ***SET name of AIS Receiver Location:
my_name = "AIS LOCATION"
 
     
   
     
  You can find the values again using google maps using the same method we used to "set your map center" previously. You will want to zoom in quite a lot until you see your street and then right click on your house and choose "set map center here". Then you can pick up the lat and long by clicking on "link to this page"  
     
  Otherwise if you want to use a GPS position then you could use this page to convert it to values usable by google maps.  
     
  ' ***SET the path to where the active ship data file (data.xml) is to be created:
strDirectory = "C:\Program Files\COAA\ShipPlotter\log files\"
 
     
  Next we want to set the directory where the data.xml file will go. Personally i change this to C:\vbship.  
     
  ' ***SET True to allow Popup message if upload succeeded:
ShowSuccess = False

' ***SET True if you want to restrict the output to the screen lat/long:
useBBox = False

 
     
  The above ones you should leave with the default settings.  
     
  Setting the upload with the included ftp script  
     
  ' ***SET True if you want to FTP the active ship data file (data.xml) to a website.
' If True, then set FTP address, user name, password, and relative path:
doFTP = True
' ***SET FTP address for your web site, eg "ftp.myISP.com":
FTPaddr = "ftp.user_FTP_server.com"
' ***SET FTP username for your site:
UserName = "user_name"
' ***SET FTP password for your site:
Password = "user_password"
' ***SET subdirectory on FTP site to put data.xml file:
RelPath = "path/to/subdirectory"
' ***SET any extra command to send to ftp server, eg "passive":
Ftpextra = ""
 
     
  The above settings in the script are for your ftp access to your webspace. I cannot help with these really as they will depend on your web host. You want to put the file in the same directory on your webspace as the google.html file or whatever you renamed it as, otherwise the page will not show your data.  
     
  Scheduling the vbs script  
     
  The vbs script needs to be scheduled so that it is running every minute or two minutes and therefore the data on your site is being kept up to date.  
     
  // Refresh the data after 'refreshInterval' seconds.
// It should not be faster than ship.vbs
var refreshInterval = 60;
 
     
  In the google.html file there is the above setting which sets how many seconds before the page is refreshed. The way new data is shown is by the page refreshing and the data.xml file being parsed to hopefully load new data. So whatever you set the above parameter to, you do not want to be uploading data in a smaller interval than that.  
     
  Personally i think 60 seconds is too short, it should be something like 120 seconds or 180 seconds. The ships cannot go very far in a few minutes. So say we set that to 120 seconds and we are going to upload our data every 120 seconds.  
     
  We schedule the upload using windows scheduler which you can find in Start / Settings / Control Panel / Scheduled Tasks  
     
 
 
     
  So we are going to add a scheduled task.  
     
 
 
     
  Click next  
     
 
 
     
  Click browse  
     
 
 
     
  Browse to where you put the vbs file. In our example we put it in C:\vbship. Select the vbs file you will be using, whether ship6.vbs or ship8.vbs and click Open.  
     
 
 
     
  Set the task to run daily and click next.  
     
 
 
     
  Set the start time to be 00:00 and the task to be performed every day.  
     
 
 
     
  The difference between windows 2000 and XP is that you will need to specify a user to run this task as in XP. Probably this should be an administrator to avoid problems.  
     
 
 
     
  Then you will want to tick the box to open advanced properties for this task and click finish. If you got some error about the user when you knew it was correct then just ignore that. You can set the password again in the next box that comes when you click finish.  
     
 
 
     
  Then on the scheduled tab choose advanced.  
     
 
 
     
  Set the interval in minutes for the task to repeat and set the until time to be 23:59. Then click ok, ok and right click on the task and select RUN.  
     
  Now you should check your website ftp folder where the file should be putting data.xml and see if there is now a data.xml in that directory. Check it is updating this file every two minutes or whatever you set it to.  
     
   
     
  Now if you check your website your page should look like this and you can now proceed to customise it the way you want so it looks nice.  
     
  Problems with this method  
     
  There can be problems with the vbs script, it can make an error when it cannot connect to the server and then stop uploading. Then you need to click ok on the error box until then it stops uploading. So it is not perfect. The errors are not too bad though. They might not occur for months or you may have three in the same week.  
     
  Let us know how you did  
     
  If you made a google maps AIS page then let us know so we can put a link on our page. If the instructions are difficult or wrong then let us know too.  
     
  Credits  
     
  We must credit the people who made this publishing method possible. The google.html and the ship.vbs were created by Ian McConnell of ShipAIS and the further development of ship.vbs in versions 6 and 8 was by W. Curt Deegan of D!V and we must not forget the author of the shipplotter software Dr. Bev M. Ewan-Smith.  
     
   
_Back to top | site map |
© Copyright 2008 AISGreece.com