Route Map Creator - v2.1 (Updated 27/08/2011)
Posted: 19 Aug 2011 20:15
So due to a quiet period at work, I dedicated some time to doing a spot of research into the multitude of JQuery plugins out there. I stumbled across a picture which caught my eye.

So I did some further digging, and discovered a rather clever way of drawing a subway map (based on the style of London Underground's very own), using a mixture of HTML5s new Canvas feature, CSS and jQuery. I jumped on the opportunity to develop it further, and made a few modifications of my own to the plugin, adding a couple of little features. I then created a very basic form to 'control' the map creator, and a somewhat pseudo-language for 'describing' the routes. Feeding this into a PHP script to parse and convert it into the needed format for the jQuery plugin.
The result can be seen by following this link:
http://www.jvassie.net/map/index.php (Hosting provided by Zernebok Ltd)
What I would suggest at first is clicking the 'Default' button which will fill in the appropriate fields with some example data, all of which is self explanitary, aside from the route description, which I will go into further detail about shortly.
First a word of caution, this is the first version of this interface/program, and as such is very basic, created in a few hours of spare time at work one day. As far as I am aware, there shouldn't be any bugs with the interface I have created, but of course if you find any, or have any queries and/or suggestions, please do feel free to speak up.
The plugin itself wasn't designed specifically to cater for the purpose I intend it to, but it should suffice for the majority of cases, and there is scope for extending it as I can, but please make sure the suggestions hasnt already been accounted for beforehand, it will save some hassle.
So, if you clicked on Default and then Create Map, you should see a basic two line map appear on the right hand side.
When creating your map, it will be easier to turn the grid and grid numbers On, by checking the respective Yes radio buttons on the form. Please note, the numbers refer to the 'line' below or to the right of the number itself, this should become apparent when you turn the grid and numbers on.
So onto the 'interesting' bit, describing the route. First, an outline of the format.
{[Route 1,#FF0000,true,0,0]
[2,2,,interchange,,A,S]
[5,2,,station,,B,S]
[9,2,,interchange,,C,S]}
Above is a 'complete' route description, which I have taken from the default settings. It describes the red line on the map. I will run through this line by line.
A route description is enclosed in curly brackets { }
Route 'parameters' and Markers are enclosed in square brackets [ ]
Marker values are comma seperated.
The first parameter in the route is what you might consider the route 'header'.
[Route 1,#FF0000,true,0,0]
Route 1 - This is the name of the route, which should be unique
#FF0000 - This is a hex colour which obviously colours the route on the map (some popular hex codes are at the bottom of the form)
true - This is either true or false, and controls wether or not this route is shown on the map legend
0 - X-offset for entire route, not currently functioning as expected, leave at 0
0 - Y-offset for entire route, not currently functioning as expected, leave at 0
And so that finishes the route header, now we move on to individual markers/route coords
As you might have guessed, the system uses a co-ordinate based system, but it also caters for decmal points, 7.15 is perfectly acceptable, as is 8.0
[2,2,,interchange,,A,S]
2 - X-Coord of the route point
2 - Y-coord of the route point
blank - This is used to describe a curve, more detail on this later. Values either N, E, S or W (or blank of course)
interchange - This describes what type of marker, station, @station, interchange, @interchange or leave it blank - More info later
blank - This describes the station size, leave blank for normal, format is h for horizontal, or v for vertical, followed by a number
(this is a measurement in line widths) - eg h3 or v5
A - label for the marker, will only show if the type of marker isnt blank
S - label position relative to marker, possible values N, NE, E, SE, S, SW, W, NW
And that essentially covers the language for describing a route!
Some Useful Pointers
Curves:
-When specifying a point, its important to remember (particularly for curves) that the coords refer to the 'end' of the segment of line.
-The direction of the curve is the direction it travels before the turn, for example try creating a map with this route description:
{[Route 1,#FF0000,true,0,0]
[2,2,,interchange,,A,S]
[3,3,E,,,,]
[3,5,,,,,]
[4,6,S,interchange,,B,S]}
You'll notice the track goes East before turning, and then goes South before turning again. Easy concept once youve got your mind around it.
Diagonals:
-Currently you only get nice rounded ends when the line is 'truly' diagonal, ie going from say [2,2] to [5,5] and the curve will always be from horizontal into or out of the diagonal.
Marker Types:
-placing @ before the marker type will mean the route wont pass through that point, but will just place a marker at that location.
-only interchanges can have a size specified
'Saving' your Map:
-Currently the only way to save your map is to print screen it and save it via MS Paint or some such
Future Changes Planned:
*New type of marker, just a simple perpendicular line that protrudes slightly.
*Specifying colours of markers more specifically
*Add vertical-to-diagonal curve support
*Add export to .png option
*Allow opening map in new window for print-screening
If you have a suggestion, please make sure it isnt on this list before asking.
Hope this is of use to you guys out there!
Version 1.1
- Have removed the need to seperate route 'parameters' by pipes
- Updated default code to reflect that
- Fixed alignment issue with N label position
Version 2.0
- You can now Register and Login as a user of the site
- New site structure and look
- New splash screen
Version 2.1
- Route descriptions now include a new 'global' settings set for the map, in the form:
[40,12,10,true,true,8,false,false]
40 - cellsize
12 - columns
10 - rows
true - grid
true - gridnumbers
8 - linewidth
false - debug
false - show legend
If you paste in your existing routes, and click create, your new route description will show your global map settings!
So I did some further digging, and discovered a rather clever way of drawing a subway map (based on the style of London Underground's very own), using a mixture of HTML5s new Canvas feature, CSS and jQuery. I jumped on the opportunity to develop it further, and made a few modifications of my own to the plugin, adding a couple of little features. I then created a very basic form to 'control' the map creator, and a somewhat pseudo-language for 'describing' the routes. Feeding this into a PHP script to parse and convert it into the needed format for the jQuery plugin.
The result can be seen by following this link:
http://www.jvassie.net/map/index.php (Hosting provided by Zernebok Ltd)
What I would suggest at first is clicking the 'Default' button which will fill in the appropriate fields with some example data, all of which is self explanitary, aside from the route description, which I will go into further detail about shortly.
First a word of caution, this is the first version of this interface/program, and as such is very basic, created in a few hours of spare time at work one day. As far as I am aware, there shouldn't be any bugs with the interface I have created, but of course if you find any, or have any queries and/or suggestions, please do feel free to speak up.
The plugin itself wasn't designed specifically to cater for the purpose I intend it to, but it should suffice for the majority of cases, and there is scope for extending it as I can, but please make sure the suggestions hasnt already been accounted for beforehand, it will save some hassle.
So, if you clicked on Default and then Create Map, you should see a basic two line map appear on the right hand side.
When creating your map, it will be easier to turn the grid and grid numbers On, by checking the respective Yes radio buttons on the form. Please note, the numbers refer to the 'line' below or to the right of the number itself, this should become apparent when you turn the grid and numbers on.
So onto the 'interesting' bit, describing the route. First, an outline of the format.
{[Route 1,#FF0000,true,0,0]
[2,2,,interchange,,A,S]
[5,2,,station,,B,S]
[9,2,,interchange,,C,S]}
Above is a 'complete' route description, which I have taken from the default settings. It describes the red line on the map. I will run through this line by line.
A route description is enclosed in curly brackets { }
Route 'parameters' and Markers are enclosed in square brackets [ ]
Marker values are comma seperated.
The first parameter in the route is what you might consider the route 'header'.
[Route 1,#FF0000,true,0,0]
Route 1 - This is the name of the route, which should be unique
#FF0000 - This is a hex colour which obviously colours the route on the map (some popular hex codes are at the bottom of the form)
true - This is either true or false, and controls wether or not this route is shown on the map legend
0 - X-offset for entire route, not currently functioning as expected, leave at 0
0 - Y-offset for entire route, not currently functioning as expected, leave at 0
And so that finishes the route header, now we move on to individual markers/route coords
As you might have guessed, the system uses a co-ordinate based system, but it also caters for decmal points, 7.15 is perfectly acceptable, as is 8.0
[2,2,,interchange,,A,S]
2 - X-Coord of the route point
2 - Y-coord of the route point
blank - This is used to describe a curve, more detail on this later. Values either N, E, S or W (or blank of course)
interchange - This describes what type of marker, station, @station, interchange, @interchange or leave it blank - More info later
blank - This describes the station size, leave blank for normal, format is h for horizontal, or v for vertical, followed by a number
(this is a measurement in line widths) - eg h3 or v5
A - label for the marker, will only show if the type of marker isnt blank
S - label position relative to marker, possible values N, NE, E, SE, S, SW, W, NW
And that essentially covers the language for describing a route!
Some Useful Pointers
Curves:
-When specifying a point, its important to remember (particularly for curves) that the coords refer to the 'end' of the segment of line.
-The direction of the curve is the direction it travels before the turn, for example try creating a map with this route description:
{[Route 1,#FF0000,true,0,0]
[2,2,,interchange,,A,S]
[3,3,E,,,,]
[3,5,,,,,]
[4,6,S,interchange,,B,S]}
You'll notice the track goes East before turning, and then goes South before turning again. Easy concept once youve got your mind around it.
Diagonals:
-Currently you only get nice rounded ends when the line is 'truly' diagonal, ie going from say [2,2] to [5,5] and the curve will always be from horizontal into or out of the diagonal.
Marker Types:
-placing @ before the marker type will mean the route wont pass through that point, but will just place a marker at that location.
-only interchanges can have a size specified
'Saving' your Map:
-Currently the only way to save your map is to print screen it and save it via MS Paint or some such
Future Changes Planned:
*New type of marker, just a simple perpendicular line that protrudes slightly.
*Specifying colours of markers more specifically
*Add vertical-to-diagonal curve support
*Add export to .png option
*Allow opening map in new window for print-screening
If you have a suggestion, please make sure it isnt on this list before asking.
Hope this is of use to you guys out there!
Version 1.1
- Have removed the need to seperate route 'parameters' by pipes
- Updated default code to reflect that
- Fixed alignment issue with N label position
Version 2.0
- You can now Register and Login as a user of the site
- New site structure and look
- New splash screen
Version 2.1
- Route descriptions now include a new 'global' settings set for the map, in the form:
[40,12,10,true,true,8,false,false]
40 - cellsize
12 - columns
10 - rows
true - grid
true - gridnumbers
8 - linewidth
false - debug
false - show legend
If you paste in your existing routes, and click create, your new route description will show your global map settings!