12 years later, I opened my first interactive map
Let’s open up the source code of my first interactive map and see what we can find.
2014, my first job as a cartographer
In May 2014, I started working for a local tourism organisation in the south of France. I was there to participate in their digital transition, which meant building an interactive map of the area. I remember driving all the way from Brussels with my desktop computer in the trunk, heading to that small town of 1200 people 1. I spent six months there, the length of the contract, between rows of corn and lines of code.
The goal was to map the area’s heritage sites, along with the walking trails that passed through them. Bonus: if I could include current and archive photos, they’d be very happy. I was almost convinced I would come up with something, but in reality I had never taken a project like this to the end.
Back then, my coding skills were more about relying on the “Google - YouTube tutorial - Stack Overflow” trinity and copy-pasting than actually understanding the code. I can assure you that copy-pasting a chunk of code and seeing it work in your own browser felt like some sort of magic. However, I decided to take some classes on the side and started working on HTML5, CSS3 and JavaScript certifications on OpenClassrooms. It helped me understand, but didn’t stop me from copy-pasting.
So, what did I actually build?
To build the map, I needed a web mapping library. At university, we’d learned how to use OpenLayers, but for this project, I wanted to try something different and chose Leaflet.
Leaflet was only three years old and hadn’t even reached version 1.0, but it already provided every function I needed:
map.setView()to set the map’s centre and zoom levelL.tileLayer()to add a basemapL.marker()to place a markerL.LayerGroup()to organise the landmarks into categories.bindPopup()to attach photographs and descriptions to each placeL.control.layers()to let users show or hide layers- and some more…
The result was a map covering 19 villages, with 57 heritage sites divided into 13 categories. It also included walking routes, photographs and descriptions.
But the page wasn’t just a Leaflet map. I also wanted visitors to be able to navigate between the villages, so I created a (quite basic) HTML menu on the left. Each village had its own JavaScript click listener, which called map.setView() with manually entered coordinates and a predefined zoom level.
The site was designed to be responsive, with the layer controls collapsing into buttons on smaller screens. The goal was to use the map in the field: either through geolocation or via QR codes placed on the heritage plaques.
For the basemap, I used Thunderforest Outdoors, one of the options available back then alongside OpenStreetMap, MapQuest and Stamen Design. This basemap has a richness and level of detail that makes it a good fit for a map focused on walking trails and rural heritage. Unlike today, Thunderforest didn’t even require an API key back then. So I had to create one to restore the map.
For the markers, I used Map Icons Collection, a website that still exists and lets users choose from lots of symbols and customise their colours. I selected an icon for each of the 13 heritage categories, downloaded the generated PNGs and hosted them on Flickr, together with the shadow images and photographs used in the popups. Flickr had somehow become my hosting service.
The walking routes required a separate workflow. I manually digitised each route in Mapbox, tracing it point by point before exporting it as GeoJSON and loading it into Leaflet. Hovering over a route displayed its name, duration, distance and difficulty, while clicking it zoomed the map to its extent. Apparently, I made the questionable choice to refer to them as "type": "Polygon" rather than "LineString". That choice opens the long list of curiosities I had some fun looking through.
Some curiosities I produced along the way
My version control system
The funniest part is that I found the source code while cleaning my emails. It seems that I didn’t understand how GitHub worked at the time, so I simply sent the project to myself by email.
Every icon was doubled
Apparently, my solution to filtering markers by category was to create every marker twice: once for the “Show all” layer (or “Tout cocher”, in french) and once for its category. When both layers were active, the marker and its shadow appeared twice at the same position.
var tout = new L.LayerGroup();
L.marker([43.166694444444445, 0.7890277777777778], {icon: sourceIcon})
.bindPopup("…")
.addTo(tout);
var source = new L.LayerGroup();
L.marker([43.166694444444445, 0.7890277777777778], {icon: sourceIcon})
.bindPopup("…")
.addTo(source);
That’s 57 places, 114 marker declarations, and twice as much code to write.
As a bonus, I had apparently decided that a rural washhouse needed to be located with fifteen decimal places of precision. That’s a precision of less than a nanometre, which is rather ambitious for a heritage inventory.
19 villages, 19 click listeners
The menu on the left followed the same very literal logic. Each village had its own click listener, coordinates and zoom level:
document.getElementById('aurignac').addEventListener('click', function () {
map.setView([43.217093, 0.881138], 16);
});
I wrote one of these for each of the 19 villages. Back then, spelling out the logic one village at a time made it easy to follow, and it got the menu working.
A rather optimistic zoom level
Looking at the geolocation settings, I found this:
map.locate({setView: true, maxZoom: 30});
A maxZoom of 30 was perhaps a little ambitious, considering that the default maximum zoom level for tile layers was only 18. At least it was consistent with the nanometre-level precision of the markers.
A little piece of Brussels in southern France
While looking through the walking routes, I found this:
"properties": {
"NAME_FRE": "AU COEUR D'AURIGNAC",
"NAME_DUT": "DUREE: 45 min </br> DISTANCE: 2,3km </br> DIFFICULTE: facile"
}
Why was hiking information stored in a field called NAME_DUT?
I had reused a dataset from a previous project involving Brussels police districts, keeping the original field names (DUT for Dutch and FRE for French) and repurposing them for my walking routes.
Making up my own CSS rules
At some point, I apparently decided that if CSS had float: left and float: right, surely float: center would exist too:
.legend i {
float: center;
}
Well, it still doesn’t. So, in case you thought it was all copy-pasting, there was also a bit of invention and experimentation involved.
Final thoughts
Despite all these questionable decisions, the map did what it was supposed to do: visitors could find the heritage sites, follow the trails and open the map from the plaques.
Looking at it now, I mostly see how I was learning: find a tool, make it work, and move on to the next problem. Today, I’d probably add a couple more steps: make it maintainable and reproducible. One GeoJSON instead of 114 marker declarations, a loop instead of 19 listeners, and Git instead of my gmail inbox.
A lot has changed in twelve years, and building the same map today would take a fraction of the time. But every now and then, I still get that same satisfaction when a complex project finally goes live and all the data displays just as it should.