This website let you poll the position of a mobile target via the ALOQA TraX Ajax API as well as add and remove distance-based update jobs.
First of all you have to enter the Application-ID (API-Key) to be able to track mobile targets within your application. If you are using the Demo MIDlet and did not change the App-Id, then aloqatest should work for you. This App-ID is only for testing purpose, since everyone can use it. If you want to start developing your own application, simply request your own API-Key.
For polling just enter the user name and click on "poll the position". If you want to add a distance-based update job to a user, then simply enter the distance in meters and the user name. The marker will be updated each time the target moves more than the given distance. Don't forget to remove the Distance-Job afterwards or just switch to another page or close the browser window.
Details on the implementation can be found below the map. We're looking forward to your feedback, so send us an email to support@aloqa.com.
This web site was developed according to the following four steps:
To actually receive results, we need to invoke actions on the ALOQA TraX Server first. After including the javascript we add a monitor job on a certain mobile "username@appid". appid is the key of this application. username represents the name of the mobile target. If you are trying out the Demo MIDlet, then the given user name must be equal to the entered name in the MIDlet. The Demo MIDlet includes a software library, which connects to our server and reports position data as requested by the following JavaScript call.
<html>
<head>
<script type="text/javascript" src="http://ajax.aloqa.com:8080/TraX/Proxy/js/trax.js"></script>
<script type="text/javascript">
<!--
var job = new TraX.DistanceJob();
job.distance = 50;
TraX.LLPM.addMonitorJob('username@appid', 'my_job_id', job);
-->
</script>
</head>
<body>
</body>
</html>
As soon the position changes we'll see an alert box popping up, informing us about the received position update. This is the default behaviour which is informative, but is of not much use to end-users. Of course, we'd like to override this default behaviour to match your needs.
In response to adding monitor jobs on mobiles, a callback function is invoked when results are received from the ALOQA TraX Server. In case of the LLPM, this callback function can be found at TraX.LLPM.onPositionUpdated(String mobileTerminal, String jobId, TraX.PositionUpdate positionUpdate).
By default, this function pops up a message box, informing us about the received position update. To override this behaviour, specify a callback function like this:
TraX.attach({
onPositionUpdated: function(mt, jobId, update) {
draw(mt, update);
}
});
Now, instead of the default callback, our custom callback will be invoked on result retrieval, which adds/moves the marker to the reported position.
For polling the position of a mobile target, we have to add the following lines.
TraX.LLPM.pollPosition('username@appid', function(update) {
draw('username@appid', update);
});
So the draw() function is called by TraX, when the position of username@appid is available.
Finally, we add a map (Google Maps) to the web site and implement the function draw(), which adds or moves the marker on the map.
Now, we're done!
More information about the Aloqa TraX Javascript API and other APIs can be found here.