Axeda VehicleTrack demonstrates how to build a simple tracking application using web standard AJAX techniques. This application maps vehicles and allows a drill down for any specific vehicle. Try it in browser or on your smartphone! The smartphone is formatted differently for its form factor. This application was developed by Axeda partner Twisthink.
Go to http://dev6.axeda.com/apps/VehicleTrack and login using username Fleet and password fleet01.

You will see your assets on the map. The bar filters trucks, vans, vehicles with alarms, or all. You will use the simulator to set these below.

When you select one of the assets, it drills into details of that asset. Alarms are shown with a location if its available. Click on the "List" to return to the vehicles page.
You can also login to this app with your Developer Connection login. Then you would see your assets listed and mapped.
To populate this information, use the Simulator to add a dataitem named "driver" of type string. Also add a string dataitem named "type" with a value of "truck" or "van". Use the Alarm tab to create a Speeding alarm, for example. And set the location of each asset by pointing to the map and sending that coordinate.

This application is purposefully simple to demonstrate how to interact with the Axeda Platform. First, the sources (html, css, js, png) are zipped and uploaded to Axeda so the platform can host them. No additional web server is required. The page has a single html which changes from a login to the mapping page. The JS code is in 3 files:
- App.js has the page logic
- Axeda.js has the web service calls
- Map.js has functions related to the Google Maps
The flow is as follows – a user logs in, which calls the Axeda login service. The login web service returns a sessionID if the username is authenticated. This sessionID is then used in each of the other web service calls. When login is successful, the page displays the map div. Now it calls Axeda service VTGetVehicleList and displays the list and maps the location of each one. When you click on a vehicle, it calls VTGetVehicleDetails and displays the details along with the location on the map.
There are two scripts in the .groovy files. These implement the web services used here, such as VTGetVehicleDetails. There are resources about Groovy scripts and how to configure them here.
The scripts are examples of creating JSON.
You can run the script from a command line using cURL
curl http://dev6.axeda.com/services/v1/rest/Scripto/execute/VTGetVehicleList?username=[your login]&password=[your password]
You can put http://dev6.axeda.com/services/v1/rest/Scripto/execute/VTGetVehicleList?... in a browser to see the JSON output. The other groovy script can be run like this http://dev6.axeda.com/services/v1/rest/Scripto/execute/VTGetVehicleDetai... where its parameter id is included in the URL. The JSON is shown directly in some browsers (Chrome, firefox on the mac...) and some browsers (IE, Firefox on windows) don't understand the format and save as a file.
which returns JSON like this:
{"devices": [
{
"id": 290,
"name": "asset2",
"vin": "asset2",
"type": "?",
"numberOfAlarms": 0,
"location": {
"lat": 42.0870521,
"lng": -71.4061876
}
},
{
"id": 118,
"name": "asset4",
"vin": "asset4",
"type": "van",
"numberOfAlarms": 0,
"location": {
"lat": 42.007897429561424,
"lng": -71.40598850180665
}
},
]}
You can run the app from a local file. The lines (in Axeda.js)
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
} catch (e) {
// must be IE
}
allow the app to call to a different host URL. When you run this from a file, the browser will prompt you to allow the communication.

