Jump to content

User:SHB2000/Getting a line on an itinerary

From Wikivoyage

A simple guide to getting a line marker for an itinerary. Such examples where it can be seen are Quebec Route 389, Stuart Highway, Oxley Highway, E8 through Finland and Norway, Tourist Drive 33 or Trans-Labrador Highway. This can also be used for getting hiking trails on a map, as seen in pages such as Mungo National Park.

If you're having difficulties or having issues with the line markers, see the troubleshooting section.

This is needed if the itinerary route doesn't exist at OpenStreetMap, or linking is too much of a hassle for your needs. Often the route should be moved to Wikimedia Commons' data: namespace, but that step is not covered here, and it can be handled later.

Getting it up

[edit]

Step 1

[edit]

You will need to go to geojson.io and then use the line tool on the right in the map frame. Then map out your route and click the last point to finish your line off. Be aware that this can take a really long time though, but the result pays the price. Do not close the tab. Keep it open, as it'll be needed for step 4.

Step 2

[edit]

To add the map, insert the following code in the article, where you want your map:
{{mapframe}}

Add any parameters from {{mapframe}}, if you want some tailoring.

Step 3

[edit]

Go to the very bottom of the article, below everything, add the following code in:

<maplink text="" latitude="" longitude="" zoom="6" group="route1" class="no-icon"> 

</maplink>

Fill the latitude and longitude in. If you want it to autoalign, then simply remove those words, and it'll look something like this:

<maplink text="" zoom="6" group="route1" class="no-icon"> 
Your .json code will go here, replacing this line
</maplink>

Keep the text="" like it is, and do not enter anything into it. Adjust the zoom if you wish, although it's the zoom on {{mapframe}} that will matter.

Step 4

[edit]

Now paste the json code that you've drawn on geojson.io between the maplinks. Basically something like

<maplink text="" zoom="6" group="route1" class="no-icon">
Your .json code will go here, replacing this line 
</maplink>

So an example of it would look like:

<maplink text="" zoom="6" group="route1" class="no-icon"> 
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "LineString",
        "coordinates": [
          [
            146.0481262207031,
            -34.29977008293614
          ],
          [
            146.0295867919922,
            -34.37177843543121
          ],
          [
            146.0460662841797,
            -34.376879043519054
          ],
          [
            146.03370666503903,
            -34.450519835492656
          ],
          [
            146.0131072998047,
            -34.46976903546482
          ],
          [
            145.99937438964844,
            -34.5478525606475
          ]
        ]
      }
    }
  ]
}
</maplink>

Then, you should all be done and your map should be showing the line.

Branching routes

[edit]

If there is a branch on your route, then you need one more line. You may note that "features": [ is plural. The "[" starts a (comma separated) list and the first "{" after it starts the first line (or whatever). You can just plot your next line at geojson.io to get both lines at the same time and paste them in as if you had just one line.

If you already closed your geojson.io window, you can go to the site again, paste in your code into the json window and then plot the second line. The other option is to copy just the code that pertains to the second line, and make sure you get the "{"s, "["s, commas and line headers right. You might also want to add a comment on what each line is about; comments in the json code start with double slash ("//") and extend to the end of the code line.

In some cases you want two separate routes. Then do as with the first line, adding a new <maplink ... ></maplink> section, with group="route2" instead of group="route1". In the full screen map window you will now have route1 and route2 as separate layers, which can be activated and deactivated separately. As default up to five separate routes can be added. If you have more, or they have names (specified in group="name") other than the standard ones, you need to add the show= parameter to the mapframe: show={{maplayers}},route6,route7 (the template adds the standard routes and markers).

If you want your lines colour coded, add that property into the "properties": {}, e.g. as "properties": {"stroke": "#00FF00"}, for a green line. The 00FF00 are the RGB values in hexadecimal: here 00 for red, FF for green and 00 for blue. If you're unsure which colour to use, simply google up "hex color picker" and where you'll then be able to choose a colour. Note that sometimes typing up the Commonwealth spelling of "hex colour picker" may not always provide results.

Duplicate routes

[edit]

Like branching routes, you'll also need more than one line if you need to duplicate your route (e.g. if the route goes on a freeway or a divided highway). Whilst there may not be much of a difference at first, it's very noticeable when you zoom in. See User:SHB2000/Getting a line on an itinerary/1 for an example of how a duplicated route would look like.

Troubleshooting

[edit]

Q: I'm getting a red box that says the following

[edit]

<maplink> problems:

  • Attribute "latitude" has an invalid value
  • Attribute "longitude" has an invalid value

A: Your <maplink> would probably have something like this: <maplink text="" latitude="" longitude="" zoom="6" group="route1" class="no-icon">

Remove the latitude and longitude.

Q: It is complaining about json syntax

[edit]

A: If the route doesn't display, there is usually red text below the map or above the edit window (after the page preview), which complains about invalid json syntax. It is easy to mess up the braces and commas on editing the json. Perhaps what you pasted wasn't the complete json code. Look at the start and end and any point you have edited and look for a missing or superfluous comma, odd indentation steps or any other irregularity. For the braces, the easiest way is to just copy the start or end of the code from your geojson.io code window, or from above, and replace whatever might be faulty. If you really need help, simply ask at the pub, and someone may be able to spot the error.

Q:Help! The markers have disappeared

[edit]

A: It is likely that the map uses the following code: {{mapframe|zoom=|height=|width=|layer=|staticmap=|align=|name=|show=city,route1,route2,route3,route4}}.

For this to work, the other markers should be mentioned along city,route1,... Easier to use the default, without the show parameter. Mostly it will be enough with {{mapframe}} without anything.

Q: Does this work on toggleable maps?

[edit]

A: It should. However, toggleable maps mean that you don't have the option to add any more values apart from route1,route2 etc. Since that's the case, then use group="route1" for all the maplines that you add. If you do wish to categorise it, use invisible text (<!-- and -->)

Q: It just doesn't work

[edit]

A: If any more help is needed then just bring up the issue on the pub and someone will eventually find the issue. Try to explain clearly what you are trying to do and what specifically doesn't work.