MapHub API tutorial
Create a map from a CSV table
This is a detailed tutorial explaining the concepts behind MapHub's API.
As part of this tutorial, you'll create a Python script, which takes a table (in CSV format) and a directory of images and creates an interactive MapHub map, entirely programmatically.
The table
title | description | url | icon_default | icon_custom | image | longitude | latitude |
---|---|---|---|---|---|---|---|
British Museum | The world-famous British Museum... | https://www.britishmuseum.org/ | museum | british.jpg | -0.128018 | 51.519294 | |
National Gallery | The crowning glory of Trafalgar Square... | star | national.jpg | -0.128374 | 51.508884 | ||
Tate Modern | Sitting grandly on the banks of the Thames is Tate Modern... | https://www.tate.org.uk/visit/tate-modern | museum | tatemodern.jpg | -0.099342 | 51.507429 | |
Victoria and Albert Museum | The V&A celebrates art and design with 3,000 years'... | https://www.vam.ac.uk/ | va.png | va.jpg | -0.171637 | 51.496884 |
The created Map
Links
Source code for the tutorial on GitHub: repo - zip archive
Table on Google Docs: link
Preparation
You need Python 3.6+ and the requests
library. The tutorial is the same for macOS, Windows and Linux. To install requests
, run
pip3 install requests
You can download all the images and the table in CSV format on the following link: zip archive. The files for this tutorial are in the map_from_table
folder.
Create your API token
If you haven't done it already, you need to make an API token for MapHub. This is explained on the following page: API docs.