Thursday 6 November 2014

TrafficControl: Looking into Javascript

The last weeks, I've spent time learning Javascript. It is very similar to C++ and, obviously, Java so the learning gap has been quite small.

I'm investigating if I can use Javascript for trafficControl, using Google Maps/Earth to handle the maps with kml files. Kml files contains the coordinates for the tracks and the stations.

As a first step, I created a Javascript that loaded a kml file to a Google Earth window and displayed that on a web page. This was quite easy with the help from Google Earth API. There, one can find some very helpful examples: https://developers.google.com/earth/


The next step was to make the Javascript analyse the coordinates in the kml file. This gave me some headache as the kml file needs to be loaded into the script itself, and this isn't allowed for web security reasons. I'll discuss that in the next post.

For web programming I can recommend http://www.w3schools.com/ with their excellent tutorials in Javascript, AJAX, JQuery, html and several other technologies. For demonstations of their code, they have a "Try it Yourself" feature, where it is possible to modify their examples and explore the code.