MapHub Documentation
Documentation for MapHub.net
New to MapHub? Start with the Getting started guide.
Choose a topic from the left side menu (☰).
For news and articles, see the MapHub Blog.
Getting started
With MapHub you make your own maps right in your browser, with nothing to install. In this guide you make your first one: you find a place and add it, draw a point, a line and an area, and save the map. It takes about a minute, and at the end you have a map of your own that you can come back to and keep building.
To follow along, log in to MapHub. You need no files.
Add a place
The quickest way to put something on your map is to search for it. MapHub finds the place for you and adds it as a marker.
-
Click New map at the top. An empty map of the world opens. The drawing tools are on the left, and the panel on the right is where you edit your map.
-
In Search at the top left, type a place and press Enter. You can search for a city, a landmark or an address. A list of matching places appears.
-
Click the place you mean, then Add. The map moves there, and the place becomes a marker on your map, with its name as the title.
Draw on the map
Not everything you want to show can be found by a search. With the drawing tools you can mark any spot, trace a route and outline an area yourself.
-
Click the Point tool on the left, then click the map. A new marker appears where you clicked. Use it for a spot of your own, like a meeting point.
-
Click the Line tool, click a few spots, then the last one again. Each click adds a point to the line, and clicking the last spot again ends it. Lines work well for routes, trails and paths.
-
Click the Polygon tool, click the corners, then the first one again. Clicking the first corner again closes the area. Areas work well for neighborhoods, parks and sites.
Save
MapHub doesn’t save your map on its own, so save it whenever you want to keep your changes.
- In the Map tab, type a Title and click Save. Your map is saved and gets a page and a link of its own. You can find it again under My maps.
Good to know
Every marker, line and area you draw starts out as “New item”. Click it to give it a title and a description in the Item tab, and to change its color. To see the name of a tool on the left, hover over it.
Maps on the Free plan are public. To send your map to others, or to keep it to a smaller circle with a paid plan, see Share a map.
To map a whole list of places at once, see Map an address spreadsheet. To find, sort and organize your saved maps, see My maps.
Map an address spreadsheet
Have a list of places with their addresses, like your stores, venues or offices? MapHub turns the spreadsheet into a map with one marker for each row. It finds every address for you, so you don’t need any coordinates. At the end you have a saved map, with the details from your spreadsheet on every marker.
To follow along, download the sample spreadsheet chicago_places.xlsx.
Prepare your spreadsheet
MapHub reads your spreadsheet by its column names. With the right two columns in place, everything else happens on its own.
- One place per row, with a Name and an Address column. The name becomes the title of each marker. Write the full address, including the city, ZIP code and country, so MapHub finds the right place. Your other columns can stay: they come along as details.
Import it
Now bring the spreadsheet into a new map. MapHub reads Excel files and CSV files.
-
In MapHub, click New map at the top. An empty map opens.
-
On the right, click Import, then Select file. Your computer’s file window opens.
-
Click your spreadsheet, then Open. The import starts right away.
-
Wait while MapHub finds each address and adds the markers. For a short list this takes only a moment. Then the map zooms in on your places, with a marker for every row.
Check and save
Take a quick look to see that everything came through, then save. MapHub doesn’t save your map on its own.
-
Click a marker to see its details. Your other columns show under the title, here the address and the type of place. A Website column turns the title into a link.
-
In the Map tab, type a title and click Save. Your map is saved with a page and a link of its own, ready to share.
Good to know
Each address MapHub looks up uses one search credit. The Free plan includes 50 credits a month and up to 100 places on a map, enough for a short list. Paid plans include more. For the details, see Search and geocoding.
If the street, city and ZIP code sit in separate columns, you don’t need to combine them. Name the columns Street, City, ZIP code and Country, and MapHub joins them into one address for you.
To give your markers a color and an icon, see Style a dataset: colors and icons. To send your map to others, see Share a map.
For all the column names MapHub understands, see XLSX / CSV import.
Style a dataset: colors and icons
When you import a spreadsheet, every row becomes a blue marker. A color and an icon make your map much easier to read at a glance. In this guide you restyle all the markers at once in a few clicks, then swap in your own marker image, like a logo. At the end every marker on your map shares the new look.
To follow along, download the sample spreadsheet chicago_places.xlsx and the marker image chicago_heart.png.
Import your data
First, put your places on the map, just as in Map an address spreadsheet. Everything you import from one file lands in a group of its own, which makes it easy to style all of it together.
-
On a new map, click Import on the right, then Select file. Your computer’s file window opens.
-
Click your spreadsheet, then Open. The import starts right away.
-
Wait while MapHub finds each address and adds the markers. A marker appears for every row, and all of them land in one group in the item list, called Imported from chicago_places.xlsx.
-
Click the group in the item list. This selects every marker in it, so what you change next applies to all of them.
Pick a color and an icon
A color and an icon tell people at a glance what kind of place a marker shows.
-
Under Set colors, click a color. All the markers change to it at once.
-
Under Set icons, click an icon, then Set. MapHub asks first, because the icon goes on every selected marker. The markers keep their new color and show the icon.
Use your own marker
For a look that is all your own, upload an image, like your logo or a symbol your readers know, and use it as the marker.
-
Click Add Icon, then Choose File. Your computer’s file window opens.
-
Click your PNG image, then Open. Use an image with a transparent background, so only its shape shows on the map. It appears at the end of the icons.
-
Click your image, then Set. Every marker in the group now shows your image.
Save
MapHub doesn’t save your map on its own, so save it once you like the look.
- Click Save. Your map keeps the new look, for you and for everyone you share it with.
Good to know
On the Free plan, a map can use up to two marker images of your own. Paid plans have no limit.
You can also give each row its own color or icon, right in your spreadsheet. To find the values, style one marker the way you like and save the map. Then click Download above the item list and choose Excel XLSX, which needs a Business plan. The file has an icon and a color column: copy their values into your own spreadsheet and import it again.
To give several groups on one map a color each, see Layers with groups.
For more about the icon and color columns, see XLSX / CSV import.
Add photos to your map
A photo shows what a place looks like, which tells your visitors far more than a marker alone. In this guide you add a photo to a place that’s already on your map, add a photo that MapHub puts where it was taken, and import a whole batch of photos at once. At the end, your photos are on the map, and a click on a marker shows its photo.
To follow along, download the sample photos chicago_photos.zip and unzip it. Three of the photos have their location saved in them, and two don’t: Navy Pier and Chicago Theatre. Then open any saved map with at least one place on it. In the video, it has a marker for the Chicago Theatre.
Add a photo to a place
When a place is already on your map, you can give it a photo. The marker stays where it is, and the photo shows whenever someone clicks it.
-
Click the Chicago Theatre marker, then Add Image. The Upload image window opens.
-
Click Choose File. A window opens where you choose a photo on your computer.
-
Click Chicago Theatre, then Open. MapHub uploads the photo and adds it to the place. Click the marker any time to see it.
Add a photo where it was taken
Most phone cameras save where each photo was taken inside the photo itself. This location data is sometimes called EXIF. MapHub reads it and puts the photo on the map for you, so you don’t have to find the place yourself.
-
Click the camera button on the left, then Select file. The camera button sits with the drawing tools on the left side of the map. It opens the Add image window.
-
Click Buckingham Fountain, then Open. MapHub adds a new marker right at the fountain, where the photo was taken, and shows the photo.
Import many photos at once
Back from a trip or a site visit with a folder full of photos? Add them all in one go instead of one by one.
-
Click Import, then drag your photos onto the box. Import is in the Map tab. Select all your photos in their folder and drag them onto the box together. MapHub uploads them one after another.
-
Click OK. Each photo is now its own item in the Images group, named after its file. Photos with a location sit on the map where they were taken. A photo without one is in the list too, but not yet on the map.
Place photos without a location
Some photos have no location saved in them. Screenshots and photos sent through a messaging app usually have lost it. MapHub adds these photos to the Images group like the others, but can’t put them on the map. You place them yourself with two clicks.
-
Click Navy Pier in the list, then Place Item. When you click a photo without a location, MapHub tells you it has no location yet. After Place Item, your next click on the map sets its location.
-
Click the map where Navy Pier is. The marker appears where you clicked, and the photo opens.
Save
Your photos become part of the map when you save it.
- Click Save. Your map is saved with all its photos. Visitors see each photo when they click its marker.
Good to know
The Free plan includes 12 images per map. All paid plans include unlimited images; see MapHub pricing.
You can upload JPG, PNG, HEIC and WebP photos of up to 15 MB each. For a big batch, resize the photos to 1856 pixels on the longer side first: they upload faster and look just as sharp on the map.
Each photo’s title comes from its file name, so give your files clear names before you upload them. Photos from a phone also get the date they were taken in their title.
To keep the location of photos from an iPhone, copy them to your computer first and upload them from there. If you upload them straight from the iPhone, their location is lost.
Layers with groups
Groups work like layers on your map: each one holds one kind of place, with its own name and color, and you can switch it off and on with a click. In this guide you import two spreadsheets, each into a group of its own, then give each group a clear name and color and try switching one off. At the end you have one map with two groups that are easy to tell apart.
To follow along, download the sample spreadsheets chicago_places.xlsx and chicago_libraries.xlsx, with eight public libraries in Chicago.
Import two spreadsheets
Start by putting both lists of places on one map. Each import lands in a group of its own, so the places from one file stay together.
-
On a new map, click Import on the right, then Select file. Your computer’s file window opens.
-
Click your first spreadsheet, then Open. The import starts right away.
-
Wait while MapHub finds each address and adds the markers. A marker appears for every row, and all of them land in one group in the item list, called Imported from chicago_places.xlsx.
-
Click Import above the item list, then Select file. This adds a second file to the same map.
-
Click your second spreadsheet, then Open. The import starts right away.
-
Wait while MapHub finds each address and adds the markers. The libraries appear next to your first places, in a group of their own.
Name and color each group
Right now both groups have long file names and the same blue markers. A short name and a color of their own let anyone see at a glance which place belongs where.
-
Click the first group and type a new name under Title. Clicking the group selects every marker in it, so what you change next applies to all of them. The new name shows in the item list right away.
-
Under Set colors, click a color. All the markers of the group change to it at once.
-
Do the same for the other group. Click it, type a name and pick a different color. Now each group has a look of its own.
Show, hide and save
When a map gets busy, you can hide a group for a moment and focus on the rest.
-
Click the eye icon to hide a group, again to show it. The group’s markers disappear from the map, and come back with the second click. Nothing is deleted: hiding only changes what you see.
-
In the Map tab, type a title and click Save. Your map is saved with both groups, ready to share.
Good to know
People who open your map see your groups in the item list too, with the same eye icons, so they can switch each group off and on for themselves. If you save while a group is hidden, it stays hidden when the map opens, so show it again before you save.
If all your places are in one spreadsheet, you can still split them into groups. Add a group column and write each row’s group name in it. Every name becomes a group of its own when you import the file. For more about this column, see XLSX / CSV import.
To give a group an icon or your own marker image as well as a color, see Style a dataset: colors and icons.
Share a map
Every MapHub map has its own link, and sharing a map is as easy as sending that link. Whoever opens it sees your map right in their browser, on a computer or a phone, with nothing to install and no account to make. In this guide you choose who can open your map, copy its link and check what people see when they open it.
To follow along, open one of your saved maps, for example the one you made in Map an address spreadsheet.
Choose who can view
Before you send the link, decide who should be able to open it:
- Public: anyone can view the map. It shows on your profile and search engines can find it.
- Secret-link: only people who have the link can view it. It’s not on your profile and search engines can’t find it.
- Private: only you and the people you add can open it. Anyone else who opens the link can’t see the map.
For sharing with a group of people, Secret-link is usually the right choice.
-
In the Map tab, click Who can view. The Map visibility window opens.
-
Choose Secret-link, then click Close. The note in the window confirms that only people who know the map’s link can view it.
-
Click Save. The new setting takes effect once the map is saved.
Your map’s link
Your map has one link: the address in your browser’s address bar while you work on the map. It’s made of your username and the map’s short name, like maphub.net/your-username/your-map. You send people this same link.
-
Under Share, click Link. Your map’s link appears. It’s the same as the one in your address bar.
-
Click the link and copy it. One click selects the whole link. Copy it with Command-C on a Mac, or Ctrl-C on Windows. Then paste it into an email or a chat message.
See what people see
The same link opens differently depending on who opens it. You see the map editor, and so do the editors you add. Everyone else sees the map ready to explore: they can zoom, move around and click places, but they can’t change anything.
- Under Visitor view, click Preview as visitor. Your map opens in a new tab, just as people see it when they open your link.
Change the link
You can change the short name at the end of the link under Edit short name, above the link. Changing it changes the link, and every link you’ve already given out stops working: in emails, in documents, in bookmarks and on other websites. If you change it, send the new link to everyone who should still have it. Maps embedded on websites aren’t affected.
On a Secret-link map, this is also how you take access back. If the link reached people who shouldn’t have it, change the short name. The old link stops working, and only the people you send the new link to can open the map.
-
In Edit short name, type a new short name. A note appears: the link changes once you save the map.
-
Click Save. Your map now has its new link, in your address bar and under Link. From now on, the old link no longer opens the map.
Good to know
You only need to send the link once. Whenever you save the map, the same link shows the latest version.
Secret-link and Private maps need a paid plan, Hobbyist or above. On the Free plan, every map is Public.
People who open your link can only view the map. To let colleagues edit it with you, see Collaborate on a map. To show the map on your own website, see Embed a map on your website. To choose what people see when they open it, such as your logo and legend, see Logo, legend and language.
Embed a map on your website
Put your MapHub map right on your own web page, so your visitors can explore it without leaving your site. You copy a short piece of text from MapHub and paste it into your website builder. At the end, your page shows a live map: visitors can zoom, move around and click places, and every change you save on MapHub shows up on your website by itself.
To follow along, open one of your saved maps, for example the one you made in Map an address spreadsheet.
How embedding works
An embedded map is like a window on your web page. Through it, your visitors see your real map on MapHub, right inside your page. Web designers call this window an “iframe”.
To make the window, MapHub gives you an embed code: one short line of text that says which map to show and how big the window is. You don’t need to understand it or change it. You only copy it from MapHub and paste it into your website.
Get the embed code
Embedding works for maps that are saved and set to Public or Secret-link under Who can view. A Private map can’t be embedded, so Embed on Website doesn’t show for it. To change this setting, see Share a map.
-
In the Map tab, click Embed on Website. A window opens with a preview of your map, just as your visitors will see it.
-
Click Code. The embed code appears. It starts with
<iframeand holds your map’s address. -
Click the code and copy it. One click selects all of the code. Copy it with Command-C on a Mac, or Ctrl-C on Windows.
Paste it into your website
Most website builders, such as Wix, Squarespace, Webflow and Google Sites, have a block for code from other sites. Depending on the builder, it is called something like Embed, HTML or Code. The website editor in the video is a made-up example; yours looks different, but the steps are the same.
-
In your website editor, add an Embed code block. Add it where the map should go on your page, for example below a heading.
-
Click the block and paste the code. Paste with Command-V on a Mac, or Ctrl-V on Windows. Some builders show the map right away, others only once you publish.
-
Click Publish. Your page goes live, with your map on it.
See your map on your website
The map on your page is the real MapHub map, so it works just like on MapHub. When your page opens, the map first shows as a picture with a play button, so your page loads quickly. One click starts the live map.
- Click a library on the map. Its details open, right on your page. Your visitors can zoom, move around and click any place on the map.
Size and position
Your website decides where the map sits on the page, and how it fits in with the rest of your design. The embed code only sets the size of the window: a width and a height, in pixels.
For a map that fits every screen, open Size in the same window and tick Responsive before you copy the code. The width becomes 100%: the map then fills the whole width your website gives it, on a computer and on a phone. If the map looks too tall or too short, change the height there, or in your website builder.
Good to know
Your website always shows the latest version of your map. Every time you save the map on MapHub, your page shows the change, with nothing to paste again. If you later change the options in the embed window, copy the new code and replace the old one on your website.
Embedding is free, on every plan, with no limit on the number of maps you embed. The embed window also has more options, such as a directions button or opening the map zoomed in on one place; they need a paid plan, Hobbyist or above. Autoplay, which starts the live map right away, without the first click, needs a Business plan.
Using WordPress? See Embed a map on WordPress.
Collaborate on a map
Most maps are teamwork: one person adds the places, another keeps the details up to date. In MapHub you add your colleagues to a map as editors, and you work on it together, each in your own browser. Only you, the map’s owner, need a Business plan. Everyone you add can use a free MapHub account.
To follow along, open one of your saved maps, for example the one you made in Map an address spreadsheet.
First, ask your colleagues to sign up
Everyone you add needs their own MapHub account, so MapHub knows who is opening the map. A free account is all they need, and it only takes a minute: ask them to go to maphub.net and click Sign up. Then ask for the username or email address they signed up with.
Add an editor
Editors can do almost everything you can: add and change places, import data, change colors and save. Only you decide who can view and who can edit the map.
-
In the Map tab, click Who can edit. The Collaboration settings window opens.
-
Choose Enabled. A field appears for the people who can edit the map.
-
Type your colleague’s username or email, then click Add new user. Their username appears in the list. To add more people, repeat this for each of them.
Add a viewer
Some people only need to look at the map, such as a client or your manager. Add them as viewers: they log in to see the map, they can’t change anything, and nobody else can open it.
-
Click Close, then Who can view. The Map visibility window opens.
-
Choose Selected users. Now only the people on your list can open the map. Editors can always open it, so you don’t need to add them here too.
-
Type their username or email, then click Add new user. They appear in the list, just like your editor did.
Save
Your colleagues get access as soon as you save the map.
- Click Close, then Save. The map is saved with its new settings. MapHub doesn’t send your colleagues a message, so let them know the map is ready.
How your colleagues find the map
Your colleagues don’t need a link. When they log in, your map is on their My maps page, with your username under its name. If you send them the map’s link, it opens in the editor for them once they log in.
- Your colleague opens My maps and clicks your map. Editors can start working right away. Viewers see the map as it is, ready to explore.
Good to know
You can all work on the map at the same time. Each of you sees the others’ changes as they make them.
Only the map’s owner needs a paid plan; everyone you add can use a free account. For editors on a Private, Secret-link or Selected users map, the owner needs a Business plan. Each seat on the plan is one person who can edit a map, you included. For more editors, add seats under Settings → Billing & plans. For viewers alone, Hobbyist or above is enough. On a Public map, you can add editors on any plan, Free included.
To remove someone, open the same window, click Remove next to their name and save the map. If a colleague changes something by mistake, see Go back to a previous version.
On MapHub Enterprise, your colleagues don’t sign up themselves: an admin invites them under Admin → User management → Invite users. After that, add them as above. To show your map to people without an account, send them its link: see Share a map.
Embed a map on WordPress
Put your MapHub map right on a page of your WordPress site, so your visitors can explore it without leaving your site. You copy a short piece of text from MapHub and paste it into a block on your page. WordPress has the block built in, so you don’t need a plugin. At the end, your page shows a live map: visitors can zoom, move around and click places.
To follow along, open one of your saved maps, for example the one you made in Map an address spreadsheet, and log in to your WordPress site.
Get the embed code
To show your map, your page needs its embed code: one short line of text that says which map to show and how big it is. You don’t need to understand it or change it, only copy it. To learn more, see How embedding works.
-
In the Map tab, click Embed on Website. A window opens with a preview of your map, just as your visitors will see it.
-
Click Size and tick Responsive. Now the map fills the width of your page’s text, on a computer and on a phone, whatever theme your site uses.
-
Click Code. The embed code appears. It starts with
<iframeand holds your map’s address. -
Click the code and copy it. One click selects all of the code. Copy it with Command-C on a Mac, or Ctrl-C on Windows.
Add it to your page
WordPress has its own block for pasting code like this, called Custom HTML. It shows you a preview, so you see your map before you save the page.
-
In WordPress, open your page, click + and search for Custom HTML. Your page opens in the WordPress editor, where you write it. The + at the top left shows all the blocks you can add.
-
Click Custom HTML, then Edit HTML. The block is added to your page, and a window opens for the code.
-
Paste the code, then click Update. Paste with Command-V on a Mac, or Ctrl-V on Windows. WordPress shows a preview of your map next to the code. After Update, the map shows right in your page.
-
Click Save. Your page is saved, with your map on it.
See your map on your page
The map on your page is the real MapHub map, so it works just like on MapHub. When your page opens, the map first shows as a picture with a play button, so your page loads quickly. One click starts the live map.
- Open your page and click a library on the map. Its details open, right on your page. Your visitors can zoom, move around and click any place on the map.
Good to know
Your page always shows the latest version of your map. Every time you save the map on MapHub, your WordPress page shows the change, with nothing to paste again.
The map must be saved and set to Public or Secret-link under Who can view; see Share a map. Embedding is free on every plan. Autoplay, which starts the live map without the first click, needs a Business plan; for the other options, see Embed a map on your website.
Only Administrators and Editors of your site can add a map in a Custom HTML block. When someone with another role, such as Author, saves the page, WordPress removes the map. On WordPress.com, the map needs a paid plan that lets you install plugins.
If WordPress removes the map anyway, install the free iframe plugin. Then add a Shortcode block instead, with [iframe src="..." width="100%" height="500"], and replace the dots with the map’s address from the embed code: the part in quotes after src=.
Go back to a previous version
Every time you or an editor saves a map, MapHub keeps that save as a version. So a mistake is never final: you can look at any earlier version and bring it back with a click. This also means you can try bigger changes without worry. At the end of this guide, your map is back the way it was before the mistake.
Here is a typical case. You work on a map of places and libraries in Chicago with a colleague. While tidying it up, your colleague deletes the libraries by mistake and saves. When you open the map, the libraries are gone. With version history you see every save, when it was made and by whom, and you bring back the version from just before your colleague’s change.
To follow along, open one of your saved maps, for example the one you made in Layers with groups.
Find the right version
Start with the list of saves, newest first. Each one shows the time and the person who saved it, so the change you’re looking for is easy to spot.
-
In the Map tab, click Version history. You see every save of your map, grouped by day. Here the newest save is your colleague’s.
-
Click View next to the save before your colleague’s change. The map shows that version, with the libraries back in place. Nothing has changed yet: you’re only looking. To look at another version, click its View.
Bring it back
When the map shows the version you want, restore it.
- Click Restore. MapHub saves this version as the newest version of your map, so you don’t need to click Save. Everyone who opens the map now sees it as it was before the mistake, and your colleague’s save stays in the list, so nothing is lost.
Good to know
Restoring a version needs a paid plan. On a Hobbyist plan, you can bring back versions from the last 7 days, and on a Business plan from the last 30 days. With MapHub Enterprise, version history is kept for as long as your organization needs: a year, several years or forever, set up to fit your agreement with us.
On the Free plan, you can look at earlier versions but not restore them. If you’d like this safety net for your maps, see MapHub pricing.
Version history is also your way back after a bigger change, for example after Simplify map on a large map. If the result isn’t what you wanted, restore the version from before.
Version history is for changes inside a map. If a whole map is gone, see Restore deleted maps.
Import boundaries
Areas like counties, districts or sales territories show a lot at a glance: where your regions are, and how they fit together. Their outlines usually come as a boundary file, most often a shapefile packed in a ZIP. In this guide you import the counties of a state and give them all one fill color. At the end you have a map with every county outlined and colored, ready to share.
To follow along, download the sample shapefile illinois_counties.zip: the 102 counties of Illinois, from the US Census Bureau.
Import your boundaries
A boundary file holds the outline of every area, along with its name. You can import the ZIP just as it is, without unpacking it.
-
On a new map, click Import on the right, then Select file. Your computer’s file window opens.
-
Click your ZIP file, then Open. The areas appear on the map, all in one group in the item list, called Imported from illinois_counties.zip.
Color the areas
A fill color makes your areas stand out from the map around them. Because all the areas share one group, you can color them all at once.
-
Click the group in the item list. This selects every area in it, so what you change next applies to all of them. In the list, each county shows its name.
-
Under Set colors, click a color. The fill and the outline of every area change to it at once.
-
Drag the Opacity slider to set how strong the fill is. A lighter fill lets the streets and place names show through. A stronger one makes the areas easier to see from far away.
Save
MapHub doesn’t save your map on its own, so save it once you like the look.
- In the Map tab, type a title and click Save. Your map is saved with its areas, ready to share.
Good to know
On the Free plan, a map holds up to 100 items, and every area counts as one. To save the 102 counties of the sample, you need a paid plan, Hobbyist or above.
Detailed boundary files can make a map slow to open for your visitors. The Simplify map button in the Map tab fixes that: it takes detail out of the outlines, so the map gets lighter and opens faster, while every area and its name stay. To learn how, see Make a big map fast with Simplify map.
GeoJSON and KML files with areas import the same way. To give each group of areas its own color, see Layers with groups.
Make a big map fast with Simplify map
When someone opens your map, MapHub sends the whole map to their phone or computer. Detailed outlines, such as county borders that follow every bend of a river, make it big, and then moving, zooming and clicking get slow. In this guide you simplify the outlines of a large map, as much as you can while they still look right. At the end your map is a fraction of its size and fast for everyone who opens it.
To follow along, download the sample west_virginia_counties.zip, import it into a new map and save it (see Import boundaries). It has the 55 counties of West Virginia from the US Census, with borders that follow every river and ridge.
Choose how simple
Only you can tell how much detail your map needs, so MapHub doesn’t decide for you. A slider lets you try different levels and see the result before you keep it.
-
In the Map tab, click Simplify map. A panel opens with a slider and the map’s Original size. The sample is 3.4 MB.
-
Drag the slider to the right, then click Preview. The further right, the more detail MapHub takes out. The Preview size shows how big the map would be: at 90%, the sample shrinks to about a tenth.
Check the shapes
A smaller map is only better if it still looks right. Have a close look before you keep it.
- Zoom in to check that the shapes still look right. The borders should still follow the rivers and ridges. If they look rough, move the slider a bit to the left and click Preview again.
Keep the result
When you like what you see, keep the simpler shapes and save.
-
Click Apply. The simpler shapes replace the detailed ones. Every area and its name stay on the map.
-
Click Save. Your map is saved with the simpler shapes. Everyone who opens it now gets the smaller, faster map.
Good to know
Changed your mind? Before you click Apply, click Cancel to go back to the original shapes. After Apply, reload the page without saving to throw the result away. After saving, restore the version from before, as in Go back to a previous version.
When you save a large map, MapHub warns you that it is big: over 100 kB on the Free plan, 1 MB on Hobbyist and 5 MB on Business. With MapHub Enterprise, the limit is set to fit your organization.
Hiding a group with the eye icon doesn’t make your map lighter: hidden groups are still sent to every visitor. To make a map lighter, simplify it, or move big layers you rarely need to a map of their own.
For more, see Simplifying a map.
My maps
The My maps page lists your own maps and the maps shared with you.
Find a map
Type in Search maps to filter by name, and sort by Recently updated, Newest first or Alphabetical. To see only your own maps or only the maps shared with you, choose Me or Others next to Owner.
To see the maps in a folder, click its tab above the maps. All shows every map.
Folders
Folders are only for organizing. They never change who can view or edit a map.
Folders are available on all plans. A map is in at most one folder.
- Create a folder: click New folder at the top right of the page. Or click ⋯ on a map and choose New folder… to create a folder and move the map into it.
- Move a map: click ⋯ on the map and pick a folder under Move to folder. Choose No folder to take it out of its folder.
- Rename or delete a folder: select the folder’s tab, click the ▾ next to its name and choose Rename or Delete folder. Deleting a folder doesn’t delete its maps.
Folders in a team
A map is in the same folder for everyone who has access to it, so a team working on the same maps sees the same folders. Each person only sees the maps they have access to. To see who created a folder, select its tab and click the ▾ next to its name.
Who can do what
- Move a map to a folder: the map’s owner and editors.
- Rename or delete a folder: the person who created it.
- Delete a map: the map’s owner, with ⋯ → Delete.
Restore deleted maps
If you have deleted a map, click Restore deleted maps at the top right of the page and click restore next to the map.
Import a MapHub Archive ZIP
To bring back a map you downloaded as Archive ZIP, or copy a map to another account, click Import MapHub Archive ZIP at the top right of the page.
Map provider keys
MapHub provides a wide range of basemaps, some of which are from commercial providers (Mapbox, ESRI, HERE, etc.). These keys configure basemap access, not address search. See Search and geocoding for search providers and credits.
Basemaps other than MapHub’s own need a paid MapHub plan.
If your map uses a commercial basemap and receives too much traffic, we ask you to sign up for the provider’s free plan and add a key here.
Without a provider key, maps with heavy usage will be limited to MapHub Classic for 24 hours.
If the provider refuses the basemap requests, for example because the key is invalid or the provider account has hit a limit or needs a payment method, the map is shown with MapHub Classic instead, and editors see a message asking them to check their provider account.
How to add map provider keys
AWS
Most new AWS accounts need no payment card; AWS asks for one in some cases.
ESRI
No payment card needed for the free tier.
HERE Maps
A payment card is required, even on the free Base plan.
Mapbox
A payment method (such as a card) is required for the satellite basemaps; you can add it when you sign up.
Thunderforest
No payment card needed for the free Hobby Project plan.
AWS provider key
How to add an AWS provider key to MapHub
This guide assumes that you already have an AWS account and can sign in to the AWS Console. Creating an AWS account is outside the scope of this guide.
Note: Most new AWS accounts can be created without a payment card, but AWS asks for one in some cases, for example if you had an AWS account before (AWS FAQ).
The video below shows the full AWS Console flow.
-
Sign in to the AWS Console.
-
In the AWS Console, select the AWS Region that you want to use from the top right corner. In the recording, this is United States (N. Virginia), whose region code is
us-east-1.Important: Copy or write down the AWS Region code. You will need to enter this region in MapHub together with the API key.
-
Using the search bar at the top of the AWS Console, type maps. In the search results dropdown, click on Maps under the Features section. This will open the Amazon Location console.
-
In the left sidebar, under Manage resources, click on API keys.
-
Click the Create API key button.
-
Enter a name for your key, for example,
maphub-basemap-key. -
Scroll down to the Resources and actions section. In the Maps Actions column, check the box next to GetTile.
-
Leave all other actions unchecked, then scroll to the bottom and click Create API key.
-
On the newly created API key’s page, click Show API key value, and then click the copy icon next to the key string.
Important: Ensure you are copying the API key value itself, not the key name or ARN.
-
Go to your MapHub account’s Map provider keys page: link
-
Paste the copied key into the AWS API key field.
-
Paste the AWS Region code from Step 2 into the AWS Region field.
-
Click Save.
-
Congratulations, you can now use AWS basemaps on MapHub!
ESRI provider key
How to add an ESRI provider key to MapHub
This guide shows how to create a new ArcGIS Location Platform account and generate an ESRI API key for MapHub.
Note: No payment card is needed: the free tier of ArcGIS Location Platform works without one. A card is only needed if you turn on pay-as-you-go to use more than the free tier.
ESRI API keys can only be valid for a maximum of 1 year. They will expire and need to be renewed annually to continue using ESRI basemaps.
- Go to the ArcGIS Location Platform.
- Click Sign up for free.
- Enter your first name, last name, and email address, then click Continue.
- On the Confirm account details page, choose a username, password, portal URL, portal display name, security question, and answer. (Note: These details are for your ArcGIS account and do not need to match your MapHub account.)
- Accept the ArcGIS Location Platform agreement and Esri privacy policy, then click Next.
- Check your email for an activation link. Click it to verify your account, then sign in.
- On the Finish setting up your account page, answer the required onboarding questions and click Finish account setup.
- On the ArcGIS Location Platform dashboard, locate the Developer credentials section and click Create developer credentials.
- Select API key credentials, then click Next.
- On Where will you use these credentials?, select Public application, then click Next.
- On Item access, select Grant access to specific items, then click Next.
- On Privileges, enable Basemaps under the Location services section, then click Next.
- On Settings, select an Expiration date. ArcGIS API keys can be valid for a maximum of one year from today.
- Leave the Referrer URLs empty, then click Next.
- On Item details, enter a title (e.g.,
maphub-api-key), then click Next. - Review the summary, make sure Generate the API key now is selected, and click Next.
- Copy the generated API key. Important: Copy the API key value immediately. The dialog is only shown once, so be sure to paste it somewhere safe before closing it. Note: Sometimes the wizard finishes without creating or showing the API key. If this happens, delete the developer credentials item you just created and start the wizard again.
- Go to your MapHub account’s Map provider keys page: link
- Paste the copied key into the ESRI API key field.
- Click Save.
- Congratulations, you can now use ESRI basemaps on MapHub!
If you do not see the dashboard wizard
Sometimes ArcGIS opens your account on the Content page instead of showing the dashboard wizard. The video below shows how to access the credential creation flow from there.
- Open your ArcGIS Content page from the top menu.
- Click the New item button.
- Select Developer credentials.
- Continue from step 9 in the guide above.
Renewing an expired API key
When your ESRI API key expires (or is about to expire), you will need to regenerate it and update it in MapHub to keep your basemaps working.
- Go to your ArcGIS Location Platform Content page.
- Click on your API key item (e.g.,
maphub-api-key). - Scroll down to the Credentials section.
- Click the Regenerate API key button.
- In the confirmation dialog, click Confirm expiration date.
- Select a new expiration date (up to a maximum of one year from today).
- Click Yes, regenerate API key.
- Copy the newly generated API key.
- Go to your MapHub account’s Map provider keys page: link
- Replace the old key by pasting the new one into the ESRI API key field and click Save.
HERE Maps provider key
How to add a HERE Maps provider key to MapHub
This guide shows how to create a HERE platform account, register an app to get a HERE API key, and use it for HERE basemaps on MapHub.
Note: HERE requires billing details, including a payment card, before you can use the platform. You start on the free Base plan and are only charged if you go over its free monthly transaction limits.
- Go to the HERE platform and click Create a free account.
- Enter your first name, last name and email address, type the characters shown in the security check, then click Verify email.
- Open the email from HERE and click Verify email.
- Choose your country or region, set a password, accept the terms, then click Next.
- On Add billing details, enter your address, phone number and payment card, click Save and review details, then Go to the platform. HERE requires a card even on the free Base plan.
- On the HERE platform home page, under Discover HERE REST APIs, click Register your app.
- Enter an app name (e.g.,
MapHub). Under Link to a subscription, select No linked subscription (Base Plan pricing applies), then click Create app. - Click the copy icon next to the API key. (You can find the key again later in the Access Manager, under your app’s Credentials.)
- In MapHub, open the menu at the top right, then Settings and Map provider keys (link).
- Paste the key into the HERE API key field and click Save.
- Open a map, go to the Basemap tab and choose one of the HERE Maps basemaps.
Congratulations, you can now use HERE basemaps on MapHub!
Mapbox provider key
How to add a Mapbox provider key to MapHub
This guide shows how to create a Mapbox account with a payment card, copy its default public token, and use it for the Mapbox satellite basemaps on MapHub.
Note: MapHub uses Mapbox only for satellite imagery (the Mapbox “Satellite” and “Satellite (labels)” basemaps), and Mapbox serves it only to accounts with a payment method (e.g. a credit card). Without one, the satellite basemaps stay black. Mapbox’s free tier still applies (for example 50,000 map loads per month): Mapbox only charges you for usage above it.
- Go to mapbox.com and click Sign up. You can sign up with email, Google or GitHub.
- Choose Individual or Business, then enter your name, country, email address, a username and a password.
- Under How do you want to start?, choose Add a card now, then enter your payment card and billing address.
- Accept the terms and click Create account.
- Open the email from Mapbox and click Verify email.
- Confirm your password and click Submit.
- On the Account overview page, under Default public token, click the copy icon. The token starts with
pk.(You can find the token again later on the Tokens page.) - In MapHub, open the menu at the top right, then Settings and Map provider keys (link).
- Paste the token into the Mapbox Public Token field and click Save.
- Open a map, go to the Basemap tab and choose one of the Mapbox basemaps.
If you already have a Mapbox account without a payment method, click Add payment method in the Mapbox Console, then copy the default public token as in step 7. If Mapbox asks what to do with your trial token, choose Rotate token.
Congratulations, you can now use Mapbox satellite basemaps on MapHub!
Thunderforest provider key
How to add a Thunderforest provider key to MapHub
This guide shows how to create a free Thunderforest account, copy its API key, and use it for Thunderforest basemaps on MapHub.
Note: Thunderforest’s free Hobby Project plan includes 150,000 tile requests per month and needs no payment card.
- Go to thunderforest.com and click Sign Up.
- Under Hobby Project, click Get Started.
- Enter your name, email address and a password, then click Create Account.
- Open the email from Thunderforest and click Confirm my account.
- Log in with your email address and password.
- On the dashboard, under API Keys, double-click the key to select it and copy it. (You can find the key again later on the Thunderforest dashboard.)
- In MapHub, open the menu at the top right, then Settings and Map provider keys (link).
- Paste the key into the Thunderforest API key field and click Save.
- Open a map, go to the Basemap tab and choose one of the Thunderforest basemaps.
Congratulations, you can now use Thunderforest basemaps on MapHub!
Import and Export
Import
XLSX / CSV import
Export
To download the whole map, choose Download. You can download it as GeoJSON, an image, Excel XLSX or CSV, GPX, KML, or an Archive ZIP.
The Archive ZIP is a full backup of the map: its items, settings, images, custom markers, legend and logos.
To download only some items, select them and choose Export selected items in the Item tab or the Download panel. You can export them as GeoJSON, KML, Excel XLSX or CSV. Excel exports need a Business plan.
Simplifying a map
Simplifying removes detail from the outlines of polygons and lines. Every item and its properties stay on the map.
In edit mode on desktop, choose Simplify map in the map panel. Pick a percentage and choose Preview. A higher percentage removes more detail. Choose Apply to keep the result or Cancel to go back to the original map.
To import boundaries such as counties or districts from a shapefile and color them, see the guide Import boundaries.
XLSX / CSV import
MapHub imports data from XLSX, XLS, ODS, CSV, and TSV files. We recommend XLSX.
New to importing? Start with the Map an address spreadsheet guide and its video.
Quick start
Say you have a spreadsheet like this:
| address | name |
|---|---|
| 1600 Pennsylvania Ave, Washington | White House |
| 10 Downing Street, London, UK | UK PM Residence |
- Open or create a map.
- Click Import and upload your file.
- MapHub finds the locations and adds them to your map.
Rows that can’t be located go to Unlocated Items — select one and click Place Item to position it manually.
How MapHub locates a row
MapHub checks your columns in this order:
- Coordinates — latitude and longitude columns → placed directly.
- Complete address — a single address column → geocoded.
- Address components — street, city, postal code, etc. → joined and geocoded.
- GeoJSON — a geojson column with geometry data.
The first match applies to the whole file. For example, if your file has both latitude/longitude and address columns, MapHub uses coordinates and skips geocoding.
Rows without a valid location go to Unlocated Items.
Column reference
Column names are matched case-insensitively. Spaces, hyphens, and underscores are treated the same (Postal_Code = postal code).
Names not listed below (like location, place, town) won’t be recognized — rename them to a supported name.
MapHub can’t import a file with two columns for the same field, like desc and description. Rename or remove one.
Coordinates
| Field | Recognized names |
|---|---|
| Latitude | lat, latitude |
| Longitude | lng, lon, long, longitude |
Latitude must be −90 to 90, longitude −180 to 180.
Complete address
A single column with the full address. MapHub geocodes each value to find its location.
| Field | Recognized names |
|---|---|
| Complete address | address, addr, full address, street address |
Only this column is geocoded. Other columns like country are not appended automatically. If your addresses need a country, include it in the address text or use the component columns below.
Address components
If your addresses are split across columns, use these names. MapHub joins them and geocodes the result.
| Field | Recognized names |
|---|---|
| House number | house number, house no, street number |
| Street | street |
| City | city |
| State | state, province, region |
| Postal code | postal code, zip, zipcode, zip code, postcode |
| Country | country, country code |
You need street and at least city or a postal code column.
Other columns
| Column | Notes |
|---|---|
title or name | Item title |
description or desc | Item description (Markdown supported) |
group | Group name (see Groups below) |
url or website | Link URL |
color | Hex color, e.g. #CC1B15 |
visible | true/false or 1/0 |
media_url | e.g. a YouTube video URL |
icon | MapHub icon id (for points) |
label, hide_text | true/false item states |
circle_radius_meters | Positive radius; use with latitude/longitude |
line_width, fill_opacity | Shape styles |
marker_rotation, marker_size, marker_offset_x, marker_offset_y | Custom marker settings |
maphub_image_url | Image reference from a MapHub export |
GeoJSON column
For advanced use, include a column named geojson with a GeoJSON Geometry string:
- Point:
{"type":"Point","coordinates":[-74.00,40.71]} - Polygon:
{"type":"Polygon","coordinates":[[[100.0,0.0],[101.0,0.0],[101.0,1.0],[100.0,1.0],[100.0,0.0]]]} - LineString:
{"type":"LineString","coordinates":[[102.0,0.0],[103.0,1.0],[104.0,0.0],[105.0,1.0]]}
Combining columns in Excel
If your columns have names MapHub doesn’t recognize (like Location or Town), you have two options: rename them to a supported name, or combine them into a new address column.
To combine, say your spreadsheet looks like this:
| A (Location) | B (Town) | C (State) | D (ZIP) | |
|---|---|---|---|---|
| Row 2 | 10 Main St | Boston | MA | 02108 |
Add a new column E called address. In cell E2, type:
=A2 & ", " & B2 & ", " & C2 & ", " & D2
This produces: 10 Main St, Boston, MA, 02108.
Drag the formula down to fill all rows. Then before uploading:
- Select the address column.
- Copy it (Ctrl+C).
- Paste as values (Ctrl+Shift+V) so it becomes plain text, not a formula.
Now upload the file and MapHub will geocode the addresses.
In Google Sheets, use Edit → Paste special → Values only.
Tip: If your data has postal codes with leading zeros (like
02108), format that column as Text in Excel before entering values. Otherwise Excel may drop the leading zero.
Groups
Browser imports place items under Imported from <filename>.
To name, color and hide these groups like layers, see the guide Layers with groups.
Use this format in the group column for nested groups:
North America/United States/California/Los Angeles
Note: use exactly this / character (not a normal /). Copy and paste it.
Sample: Multi-level group sample
Re-importing a MapHub export
MapHub exports include longitude, latitude, and geojson columns, even when empty. If you want to re-import for address geocoding, delete the longitude and latitude columns first. Otherwise MapHub uses coordinate mode and skips geocoding.
API imports don’t geocode — provide coordinates or GeoJSON directly.
Sample files
Download a sample from this map (click Download → Excel XLSX or CSV):
The museums.csv sample has Name, Description, and Address columns. Each address includes the country (e.g. “Rue de Rivoli, 75001 Paris, France”) — download it to try.
Credits
Address geocoding uses the map owner’s credits, one per unique address. Choose Open Data or Commercial under Address lookup provider in the Import panel; the panel also shows how many credits are used this month. If credits don’t cover every address, MapHub tells you before it starts how many rows it can import, and you can import those rows or cancel. Rows whose addresses aren’t covered are left out. If no rows can be imported, the process stops. See Search and geocoding — Credits for amounts and when new credits arrive.
Rows with latitude/longitude or without an address are always imported and never use credits.
Search and geocoding
Geocoding turns a place name or address into a location on a map. MapHub uses it in two places:
- Search box — the search in the top-left corner of the map.
- Spreadsheet import — when you upload a file with addresses. See XLSX / CSV import.
Providers
| Provider | Notes |
|---|---|
| Open Data | Great for everyday searches. Available on all plans. |
| Commercial | Best results. Available on paid plans. |
| Free | Basic results. Not available for spreadsheet import. |
What each plan includes
The map owner’s plan applies, including when you edit someone else’s map.
| Plan | Editor search | Visitor search | Spreadsheet import |
|---|---|---|---|
| Free | Open Data, Free | Off | Open Data |
| Hobbyist | Commercial, Open Data, Free | Free | Commercial, Open Data |
| Business | Commercial, Open Data, Free | Commercial, Open Data, Free | Commercial, Open Data |
| Enterprise | Commercial, Open Data, Free | Commercial, Open Data, Free | Commercial, Open Data |
Choosing a provider
In the right sidebar, open Map → Visitor view → Search (or Map → Search on private maps):
- While editing — your default on every map you edit.
- Visitors — the provider visitors use on this map. Tick Also in embeds to show search on embedded maps too. Only the map owner sees this setting.
To switch temporarily, use the provider button in the top-left search box. If results are showing, the search runs again with the new provider. Reloading the page brings back your default.
For spreadsheet imports, choose the provider under Address lookup provider in the Import panel. It starts with your While editing provider.
Credits
Open Data and Commercial searches and imports use monthly credits. Free search doesn’t. One search or one unique imported address uses one credit.
| Plan | Open Data | Commercial editor | Commercial visitor |
|---|---|---|---|
| Free | 50 | — | — |
| Hobbyist | 500 | 25 | — |
| Business (per seat) | 2,000 | 100 | 800 |
| Enterprise | Custom | Custom | Custom |
Open Data covers all Open Data searches and imports. Commercial editor covers Commercial searches while editing and Commercial imports. Commercial visitor covers visitor and embed searches.
Credits belong to the map owner, so searches by collaborators and visitors use the owner’s credits. New credits arrive on the 1st of each month.
You can see this month’s usage in the Search dialog, the Import panel and under Settings → Billing & plans.
When credits run low
When a provider’s credits run out, search with it pauses until the 1st of next month. For more credits every month, upgrade your plan, or add seats on Business.
For spreadsheet imports, MapHub checks your credits before it starts. If they don’t cover every address, it tells you how many rows it can import, and you can import those rows or cancel. Rows whose addresses aren’t covered are left out. If no rows can be imported, the process stops. Rows with latitude/longitude or without an address are always imported and never use credits.
Hide items from visitors
Hide an item or a whole group so that only you and your collaborators can see it. Visitors and embedded maps don’t show it. Useful for drafts, or for places you want to switch off for a while without deleting them.
Requires a Business or Enterprise plan.
How to hide
- In edit mode, select the item or group. You can select several at once.
- In the Item tab, tick Hide from visitors.
- Save the map.
To show it again, untick the box and save.
In the item list, hidden items have a crossed-out person icon.
Groups
Hiding a group hides everything inside it.
While a group is hidden, its items’ checkboxes are greyed out. Unhide the group first to change them. Items you hid one by one stay hidden when you unhide the group.
Check what visitors see
Save the map, then choose Map → Visitor view → Preview as visitor (desktop only, not available on private maps).
Downloads
Visitors’ downloads never include hidden items. Your downloads as an editor do.
If you leave the Business plan
Hidden items stay hidden, but you can’t save the map until you unhide them.
Logo, legend and language
Customize what visitors see on your map: the info box with a legend image, your business logo, and the language of the map labels.
Requires a Business or Enterprise plan. All settings are in the map editor on a computer. Save the map after changing them.
Where to find the settings
Most settings are in the Map tab, in the Visitor view section. It only appears on Public and Secret-link maps. If your map is Private, change it under Who can view first.
Legend
The info box is the card in the bottom-right corner of the map. It can show the map’s title and author, its description and a legend image.
- In the Map tab, click Visitor view → Info box.
- Click Upload image and choose your legend (PNG, JPG, HEIC or WebP).
- Tick what the info box should show: Title and author, Description, Legend image.
- Save the map.
If only Legend image is ticked, the info box takes the size of the image. If nothing is ticked, visitors don’t see an info box.
Business logo
- In the Map tab, click Visitor view → Logo.
- Choose Custom logo and upload a PNG file. A transparent background looks best.
- Save the map.
The logo is shown in the bottom-left corner of the map. To remove it, choose No logo.
Basemap language
- Open the Basemap tab and click Customize at the top.
- Choose a language under Basemap language.
- Save the map.
Works on the MapHub basemaps: Classic, Earth, Elegant and Dark. On other basemaps, choosing a language switches the map to MapHub Classic.
Check what visitors see
Save the map, then click Map → Visitor view → Preview as visitor.
MapHub API
The HTTP API is inspired by the Dropbox API v2.
-
MapHub API uses HTTP POST requests with JSON arguments and JSON responses.
-
Request authentication is via API keys using the
Authorization: Token <api_key>request header. -
You can create API keys from the Settings page:
-
To use the API, you need to verify your email address.
-
Errors are returned in the
errorJSON field, status code is always 200.A successful response has no
errorfield.
Request and response formats
Endpoints accept arguments as JSON in the request body and return results as JSON in the response body.
The Upload and Append endpoints accept file content in the request body, so their arguments are instead passed as JSON in the MapHub-API-Arg request header.
Endpoints
You can see the currently implemented endpoints in the left side menu.
If you’d like to see more API endpoints or need some added features, please contact us.
MapHub Enterprise API usage
The API for Enterprise users is the same as with the public website, except the maphub.net URL is changed to your server’s URL. For example, instead of
https://maphub.net/api/1/map/list
please use
https://companyname.maphub.net/api/1/map/list
List maps
https://maphub.net/api/1/map/list
List all maps available for the user.
Arguments
This endpoint takes no arguments.
Response
The response returns 3 keys, each containing list of maps:
- owner: the user’s maps
- editor: maps where the user can edit, but is not the owner
- viewer: maps where the user can view, but cannot edit and is not the owner
For each map in the lists, the following properties are returned:
- id: id of the map
- url: URL of the map
- embed_url: embed URL of the map, for use in an
<iframe>. Use this URL instead of building one from the map id. - owner: map owner’s username
- short_name: short name of the map, used in the URL
- title: title of the map
- visibility: visibility mode of the map. One of
public,unlisted,private,select.
Code example
curl
curl https://maphub.net/api/1/map/list \
--header 'Authorization: Token <api_key>' \
--data-raw ''
Python
import requests
url = 'https://maphub.net/api/1/map/list'
api_key = '<api_key>'
headers = {'Authorization': 'Token ' + api_key}
r = requests.post(url, headers=headers)
print(r.json())
Get map
https://maphub.net/api/1/map/get
Get all information about single map, including GeoJSON.
Arguments
- map_id (required): the id of the map. To find out a map’s id, please use the list maps endpoint.
Response
The response returns the following keys:
-
id: The id of the map.
-
url: The full URL of the map.
-
embed_url: The embed URL of the map, for use in an
<iframe>. Use this URL instead of building one from the map id. -
owner: The map owner’s username.
-
short_name: The short name of the map, used in the URL.
-
title: The title of the map.
-
description: The description of the map.
-
geojson: The GeoJSON for the map. This includes information related to groups, custom icons and images as well.
-
basemap: The basemap used by the map.
-
visibility: The visibility mode of the map. One of
public,unlisted,private,select. -
collaborate: Whether collaboration is enabled/disabled for the map. True/False
-
viewer_users: The list of specified viewers, if visibility mode is
select. -
editor_users: The list of editors, if collaboration is enabled.
-
created_date: The date when the map was created. ISO datetime string in UTC timezone.
-
modified_date: The date when the map was last updated. ISO datetime string in UTC timezone.
-
images: The list of image ids present in the map’s GeoJSON.
-
markers: The list of marker ids present in the map’s GeoJSON. Markers = custom icons on the web interface.
Code example
curl
curl https://maphub.net/api/1/map/get \
--header 'Authorization: Token <api_key>' \
--data-raw '{"map_id": 12345}'
Python
import requests
url = 'https://maphub.net/api/1/map/get'
api_key = '<api_key>'
args = {
'map_id': 12345,
}
headers = {'Authorization': 'Token ' + api_key}
r = requests.post(url, json=args, headers=headers)
print(r.json())
Upload map
https://maphub.net/api/1/map/upload
Upload a file and create a new map.
When empty is used for file_type, an empty map will be created.
A static image is automatically generated for the uploaded map.
For this endpoint you’ll need to
- send the arguments as a JSON encoded string in the
MapHub-API-Argheader - send the uploaded file as binary data in the request body (except with
emptyfile_type)
Arguments
- file_type (required): one of
empty,kml,gpx,geojson,csv, orexcel. For KMZ files, usekml. For XLS, XLSX, and ODS files, useexcel. For TSV and TXT files, usecsv. - visibility (required): The visibility option of the map. One of
public,unlisted,private. - title (optional): the preferred title of the map
- description (optional): the preferred description of the map
- short_name (optional): the short name of the map, visible in the URL. This is just a preference, the final URL will be returned in the response.
Response
- id: id of the map
- url: URL of the map
- embed_url: embed URL of the map, for use in an
<iframe>. Use this URL instead of building one from the map id. - owner: map owner’s username
- short_name: short name of the map, used in the URL
- title: title of the map
- visibility: visibility mode of the map. One of
public,unlisted,private,select.
Limitations
Following limits apply to uploads:
- maximum file size 15 MB
- maximum processing time 2 minutes
On a MapHub Enterprise server, there are no limits. If you are interested in MapHub Enterprise, contact us.
Multi-level groups
You can create multi-level groups by using the following format for “group”.
North America/United States/California/Los Angeles
Note, you have to use exactly this / character. Please copy and paste it. It is not the same as the normal / character.
Code example
curl with file
curl https://maphub.net/api/1/map/upload \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"file_type": "gpx", "visibility": "public"}' \
--data-binary @test.gpx
curl with geojson data
curl https://maphub.net/api/1/map/upload \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"file_type": "geojson", "visibility": "public"}' \
--data-raw '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [12.34, 56.78]}, "properties": {"title": "Test point", "description": "Test description", "group": 12345}}], "groups": [{"title": "Test group", "id": 12345}]}'
Python with file
import json
import requests
url = 'https://maphub.net/api/1/map/upload'
api_key = '<api_key>'
args = {
'file_type': 'gpx',
'title': 'Sample Title',
'short_name': 'short name',
'visibility': 'public',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
with open('test.gpx', 'rb') as f:
r = requests.post(url, headers=headers, data=f)
print(r.json())
Python with geojson data
import json
import requests
url = 'https://maphub.net/api/1/map/upload'
api_key = '<api_key>'
args = {
'file_type': 'geojson',
'title': 'Sample Title',
'short_name': 'short name',
'visibility': 'public',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [12.34, 56.78]},
"properties": {
"title": 'Test point',
"description": 'Test description',
"group": 12345,
},
}
],
"groups": [{"title": 'Test group', "id": 12345}],
}
r = requests.post(url, headers=headers, data=json.dumps(geojson))
print(r.json())
Python empty map
import json
import requests
url = 'https://maphub.net/api/1/map/upload'
api_key = '<api_key>'
args = {
'file_type': 'empty',
'title': 'Sample Title',
'short_name': 'short name',
'visibility': 'public',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
r = requests.post(url, headers=headers)
print(r.json())
Update map
https://maphub.net/api/1/map/update
Update a map, including the GeoJSON.
For GeoJSON it means that the contents of the whole map is replaced with the new supplied geojson data.
Only the included arguments will be updated. For example if only short_name is included, nothing else will be changed.
When updating the GeoJSON of a map, images and markers are “linked”, you do not need to upload them again.
Static map image is not updated automatically. If you’d like to update it, call the refresh map image endpoint manually.
A new map version is not saved.
Arguments
-
map_id (required): the id of the map. To find out a map’s id, please use the list maps endpoint.
-
title (optional): The title of the map.
-
short_name (optional): The short name of the map, used in the URL.
-
description (optional): The description of the map.
-
geojson (optional): The GeoJSON for the map. This includes information related to groups, custom icons and images as well.
-
basemap (optional): The basemap used by the map.
-
visibility (optional): The visibility setting of the map. One of
public,unlisted,private.
Response
- id: id of the map
- url: URL of the map
- embed_url: embed URL of the map, for use in an
<iframe>. Use this URL instead of building one from the map id. - owner: map owner’s username
- short_name: short name of the map, used in the URL
- title: title of the map
- visibility: visibility mode of the map. One of
public,unlisted,private,select.
Code example
curl
curl https://maphub.net/api/1/map/update \
--header 'Authorization: Token <api_key>' \
--data-raw '{"map_id": 12345, "short_name": "test_short_name_abc", "title": "Test Title ABC", "geojson": {"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [12.34, 56.78]}, "properties": {"title": "Test point", "description": "Test description", "group": 12345}}], "groups": [{"title": "Test group", "id": 12345}]}}'
Python
import requests
url = 'https://maphub.net/api/1/map/update'
api_key = '<api_key>'
geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [12.34, 56.78]},
"properties": {
"title": 'Test point',
"description": 'Test description',
"group": 12345,
},
},
{
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [13.34, 57.78]},
"properties": {
"title": 'Test point 2',
"description": 'Test description',
"group": 12345,
},
}
],
"groups": [{"title": 'Test group', "id": 12345}],
}
args = {
'map_id': 12345,
'short_name': 'test_short_name_abc',
'title': 'Test Title ABC',
'geojson': geojson,
}
headers = {'Authorization': 'Token ' + api_key}
r = requests.post(url, json=args, headers=headers)
print(r.json())
Append map
https://maphub.net/api/1/map/append
Upload a file and append to an existing map.
Static map image is not updated automatically. If you’d like to update it, call the refresh map image endpoint manually.
A new map version is not saved.
For this endpoint you’ll need to
- send the arguments as a JSON encoded string in the
MapHub-API-Argheader - send the uploaded file as binary data in the request body
Arguments
- map_id (required): The id of the map. To find out a map’s id, please use the list maps endpoint.
- file_type (required): One of
kml,gpx,geojson,csv, orexcel. For KMZ files, usekml. For XLS, XLSX, and ODS files, useexcel. For TSV and TXT files, usecsv. - new_group (optional): A string that names a group for the imported content. For table imports, this group becomes the import root and preserves source subgroups below it. For other formats, all imported items are placed directly in this group.
Response
- id: id of the map
- url: URL of the map
- embed_url: embed URL of the map, for use in an
<iframe>. Use this URL instead of building one from the map id. - owner: map owner’s username
- short_name: short name of the map, used in the URL
- title: title of the map
- visibility: visibility mode of the map. One of
public,unlisted,private,select.
Limitations
Following limits apply to uploads:
- maximum file size 15 MB
- maximum processing time 2 minutes
On a MapHub Enterprise server, there are no limits. If you are interested in MapHub Enterprise, contact us.
Code example
curl with file
curl https://maphub.net/api/1/map/append \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"map_id": 12345, "file_type": "kml"}' \
--data-binary @test.kml
curl with geojson data
curl https://maphub.net/api/1/map/append \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"map_id": 12345, "file_type": "geojson"}' \
--data-raw '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [23.45, 34.56]}, "properties": {"title": "Test point", "description": "Test description", "group": 12345}}], "groups": [{"title": "Test group", "id": 12345}]}'
Python with file
import json
import requests
url = 'https://maphub.net/api/1/map/append'
api_key = '<api_key>'
args = {
'map_id': 12345,
'file_type': 'kml',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
with open('test.kml', 'rb') as f:
r = requests.post(url, headers=headers, data=f)
print(r.json())
Python with geojson data
import json
import requests
url = 'https://maphub.net/api/1/map/append'
api_key = '<api_key>'
args = {
'map_id': 12345,
'file_type': 'geojson',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [12.34, 56.78]},
"properties": {
"title": 'Test point',
"description": 'Test description',
"group": 2345,
},
}
],
"groups": [{"title": 'Test group 234', "id": 2345}],
}
r = requests.post(url, headers=headers, data=json.dumps(geojson))
print(r.json())
Refresh static map image
https://maphub.net/api/1/map/refresh_image
Refresh the static image of a map.
Static map images are used by embeds and the Download / Image dialog.
If the map is using a premium basemap, you need to add the basemap’s API key first.
Note: This endpoint is very resource intensive, please limit it to max. 1 call every 5 minutes.
Arguments
- map_id (required): the id of the map. To find out a map’s id, please use the list maps endpoint.
Response
The response returns the following keys:
- id: id of the map
- url: URL of the map
- embed_url: embed URL of the map, for use in an
<iframe>. Use this URL instead of building one from the map id. - owner: map owner’s username
- short_name: short name of the map, used in the URL
- title: title of the map
- visibility: visibility mode of the map. One of
public,unlisted,private,select.
Code example
curl
curl https://maphub.net/api/1/map/refresh_image \
--header 'Authorization: Token <api_key>' \
--data-raw '{"map_id": 12345}'
Python
import requests
url = 'https://maphub.net/api/1/map/refresh_image'
api_key = '<api_key>'
args = {
'map_id': 12345,
}
headers = {'Authorization': 'Token ' + api_key}
r = requests.post(url, json=args, headers=headers)
print(r.json())
Upload image
https://maphub.net/api/1/image/upload
This endpoint uploads a JPG, PNG, HEIC or WebP image, resizes it to responsive sizes and stores it on the server.
The endpoint returns the image_id of the uploaded image, as well as width/height and other properties that you need to use when uploading or updating a GeoJSON of map.
When updating the GeoJSON of a map, images and markers are “linked”, you do not need to upload them again.
Images are automatically deleted once they are no longer used in any map.
For this endpoint you’ll need to
- send the arguments as a JSON encoded string in the
MapHub-API-Argheader - send the uploaded file as binary data in the request body
Arguments
- file_type (required): one of
jpg,jpeg,png,heic,webp
Response
- image_id: the id of the image
- width: the width of the image in pixels
- height: the height of the image in pixels
- tip_color: the color of the image popup’s tip at the bottom center
- avg_color: the average color of the image, displayed before loading
- has_gps: if the image has GPS information, true/false
- geometry: GeoJSON geometry if the image has GPS information. null if not.
- date_str: image’s original created date in a human readable text
- date_iso: image’s original created date in ISO datetime format
Limitations
Following limits apply to uploads:
- maximum file size 15 MB
- maximum processing time 2 minutes
On a MapHub Enterprise server, there are no limits. If you are interested in MapHub Enterprise, contact us.
Code example
curl
curl https://maphub.net/api/1/image/upload \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"file_type": "png"}' \
--data-binary @test.png
Python
import json
import requests
url = 'https://maphub.net/api/1/image/upload'
api_key = '<api_key>'
args = {
'file_type': 'jpg',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
with open('test.jpg', 'rb') as f:
r = requests.post(url, headers=headers, data=f)
print(r.json())
Upload marker
https://maphub.net/api/1/marker/upload
Markers are custom icons which can be uploaded for points.
This endpoint uploads a PNG image, resizes it to the right size and stores it on the server.
The endpoint returns the marker_id of the uploaded marker, that you need to use when uploading or updating a GeoJSON of map.
When updating the GeoJSON of a map, images and markers are “linked”, you do not need to upload them again.
Markers are automatically deleted once they are no longer used in any map.
For this endpoint you’ll need to
- send the arguments as a JSON encoded string in the
MapHub-API-Argheader - send the uploaded file as binary data in the request body
Arguments
- file_type (required): currently only supported:
png
Response
- marker_id: the id of the marker
Limitations
Following limits apply to uploads:
- maximum file size 15 MB
- maximum processing time 2 minutes
On a MapHub Enterprise server, there are no limits. If you are interested in MapHub Enterprise, contact us.
Code example
curl
curl https://maphub.net/api/1/marker/upload \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"file_type": "png"}' \
--data-binary @test.png
Python
import json
import requests
url = 'https://maphub.net/api/1/marker/upload'
api_key = '<api_key>'
args = {
'file_type': 'png',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
with open('test.png', 'rb') as f:
r = requests.post(url, headers=headers, data=f)
print(r.json())
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, images and table for the tutorial: 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 the scripts, 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.
Create a new map
Step 2: Create a new map
To create an empty map, we’ll call the Upload map endpoint. The core function is the following:
url = 'https://maphub.net/api/1/map/upload'
args = {
'file_type': 'empty',
'title': 'London Attractions',
'short_name': 'london-attractions',
'visibility': 'public',
}
headers = {
'Authorization': 'Token ' + API_KEY,
'MapHub-API-Arg': json.dumps(args),
}
res = requests.post(url, headers=headers)
data = res.json()
When used with file_type=empty, the Upload map endpoint creates a new map.
In the script, we save the returned map’s id into a JSON file (map_data.json). In later steps, we’ll read the map id from this JSON file.
map_data.json sample
{
"id": 12345,
"url": "https://maphub.net/test/london-attractions",
"embed_url": "https://maphub.net/embed_h/AbCdEfGh12345678",
"owner": "test",
"short_name": "london-attractions",
"title": "London Attractions",
"visibility": "public"
}
Full script file
Upload images and markers
Step 3: Upload images and markers
MapHub treats images separate from maps. If you’d like to use an image in a map, you’ll have to upload it first. Once an image is uploaded, you have to store the returned information about the image, so you can later use it in a map. In this tutorial, we store this information in a JSON file, next to each image.
A note about markers: markers are user-uploaded, custom icons for points. You have to upload them in advance, just like images.
The code for this step is in 2 parts:
1. Loop through each image and marker to upload them
# for each image in the images dir
for file_path in list(IMAGES_DIR.glob('*.jpg')) + list(IMAGES_DIR.glob('*.png')):
# upload image
upload_image_marker('image', file_path)
# for each marker in the markers dir
for file_path in MARKERS_DIR.glob('*.png'):
# upload marker
upload_image_marker('marker', file_path)
2. The core of the upload function:
def upload_image_marker(kind, file_path):
# path where we store the info JSON
info_json = file_path.parent / f'{file_path.stem}.json'
# if the JSON file exists, the image/marker is already uploaded, skip the upload
if info_json.is_file():
print(f'Skipping {kind} {file_path.name}')
return
url = f'https://maphub.net/api/1/{kind}/upload'
# use the file's extension as file_type
args = {
'file_type': file_path.suffix[1:],
}
headers = {
'Authorization': 'Token ' + API_KEY,
'MapHub-API-Arg': json.dumps(args),
}
with open(file_path, 'rb') as f:
# the upload request
res = requests.post(url, headers=headers, data=f)
data = res.json()
# check that upload was successful, if not print error
if f'{kind}_id' not in data:
print(data['error'])
return
# save the image_info dict to disk
with open(info_json, 'w') as f:
json.dump(data, f, indent=2)
image.json sample
{
"image_id": "nnhio1dgalldkf4x",
"width": 640,
"height": 360,
"tip_color": "#bfbbcb",
"avg_color": "#8a93a9",
"has_gps": false,
"geometry": null,
"date_str": null,
"date_iso": null
}
marker.json sample
{
"marker_id": "eeumhz32iv0yfcfn"
}
Full script file
2_upload_images_and_markers.py
MapHub GeoJSON
Step 4: Make the GeoJSON
In this step, we’ll generate a GeoJSON from the CSV table data. Later we call the Update map endpoint with the generated GeoJSON.
GeoJSON on MapHub
Every map on MapHub is stored as a GeoJSON document. All map data: points, polygons, etc. are stored in this single document. To understand the structure of a MapHub map, the best thing is to download a map you’ve created as GeoJSON.
You can do this by opening one of your maps on MapHub.net and clicking on the “Download” button in the right side panel and then selecting “GeoJSON”.
For example, the finished map of this tutorial has the following GeoJSON:
{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"id": 515312282,
"geometry": {
"type": "Point",
"coordinates": [-0.128018, 51.519294]
},
"properties": {
"title": "British Museum",
"description": "The world-famous British Museum exhibits the works of man from prehistoric to modern times, from around the world. Highlights include the Rosetta Stone, the Parthenon sculptures and the mummies in the Ancient Egypt collection.",
"url": "https://www.britishmuseum.org/",
"marker-symbol": "museum",
"image": {
"id": "pwasvdaus75tnn3w",
"w": 640,
"h": 360,
"tip_color": "#bdbbcb",
"avg_color": "#8895aa"
}
}
},
{
"type": "Feature",
"id": 521910492,
"geometry": {
"type": "Point",
"coordinates": [-0.128374, 51.508884]
},
"properties": {
"title": "National Gallery",
"description": "The crowning glory of Trafalgar Square, London's National Gallery is a vast space filled with western European paintings from the 13th to the 19th centuries. Find works by masters such as Van Gogh, da Vinci, Botticelli, Constable, Renoir, Titian and Stubbs.",
"marker-symbol": "star",
"image": {
"id": "pr1xhpavd1atxs5l",
"w": 640,
"h": 360,
"tip_color": "#8d857b",
"avg_color": "#8c8c8e"
}
}
},
{
"type": "Feature",
"id": 1233836134,
"geometry": {
"type": "Point",
"coordinates": [-0.099342, 51.507429]
},
"properties": {
"title": "Tate Modern",
"description": "Sitting grandly on the banks of the Thames is Tate Modern, Britain's national museum of modern and contemporary art. Its unique shape is due to it previously being a power station. The gallery's restaurants offer fabulous views across the city.",
"url": "https://www.tate.org.uk/visit/tate-modern",
"marker-symbol": "museum",
"image": {
"id": "yibgsqadfifyaste",
"w": 640,
"h": 360,
"tip_color": "#8493ab",
"avg_color": "#9c9ea1"
}
}
},
{
"type": "Feature",
"id": 3383498660,
"geometry": {
"type": "Point",
"coordinates": [-0.171637, 51.496884]
},
"properties": {
"title": "Victoria and Albert Museum",
"description": "The V&A celebrates art and design with 3,000 years' worth of amazing artefacts from around the world. A real treasure trove of goodies, you never know what you'll discover next: furniture, paintings, sculpture, metalwork and textiles; the list goes on.",
"url": "https://www.vam.ac.uk/",
"marker_id": "bvd5ykfilp7ekxyh",
"image": {
"id": "ikxqpaqycbrpannw",
"w": 640,
"h": 360,
"tip_color": "#d1b896",
"avg_color": "#725d42"
}
}
}
],
"groups": []
}
Note: Some keys like markers, properties and export are not displayed here, as they are not important for this tutorial.
The id fields are optional, you can leave them out and they’ll be automatically created.
Creating the GeoJSON from the table data
The following function is the core of this tutorial, it creates a GeoJSON from the table data we have. It also reads information from the image and marker JSONs and inserts it into the GeoJSON.
def create_geojson_from_csv(csv_file):
assert csv_file.is_file()
features = []
with open(csv_file, newline='') as f:
# auto-detect the CSV dialect
dialect = csv.Sniffer().sniff(f.read())
f.seek(0)
# use DictReader which gives a dict for each row
reader = csv.DictReader(f, dialect=dialect)
# for each row in the CSV file
for row in reader:
row = dict(row)
lat = float(row['latitude'])
lon = float(row['longitude'])
# basic properties
properties = {
"title": row['title'],
"description": row['description'],
"url": row['url'],
}
# if we have an icon from the default set, use it
if row['icon_default']:
properties['marker-symbol'] = row['icon_default']
# if we have a custom icon, use the uploaded marker
if row['icon_custom']:
marker_info = get_image_marker_info('marker', row['icon_custom'])
if marker_info:
properties['marker_id'] = marker_info['marker_id']
# if we have an image, use the uploaded image
if row['image']:
image_info = get_image_marker_info('image', row['image'])
if image_info:
properties['image'] = {
'id': image_info['image_id'],
'w': image_info['width'],
'h': image_info['height'],
'tip_color': image_info['tip_color'],
'avg_color': image_info['avg_color'],
}
# create the GeoJSON for the item
feature = {
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [lon, lat]},
"properties": properties,
}
features.append(feature)
geojson = {
"type": "FeatureCollection",
"features": features,
}
return geojson
The core of get_image_marker_info helper function:
def get_image_marker_info(kind, file_name):
assert kind in {'image', 'marker'}
if kind == 'image':
file_path = IMAGES_DIR / file_name
else:
file_path = MARKERS_DIR / file_name
info_json = file_path.parent / f'{file_path.stem}.json'
with open(info_json) as f:
return json.load(f)
In the next step, we will call the Update map endpoint with the generated GeoJSON.
Multi-level groups
You can create multi-level groups by using the following format for “group”:
North America/United States/California/Los Angeles
Note, you have to use exactly this / character. Please copy and paste it. It is not the same as the normal / character.
Group paths are unique within a map: if two groups have the same path, saving the map renames the later ones to Name (2), Name (3) and so on.
Update map
Step 5: Update the map
Time to call the Update map endpoint with the generated GeoJSON from the previous step.
def update_map(geojson):
with open(MAP_DATA_JSON) as f:
map_data = json.load(f)
url = 'https://maphub.net/api/1/map/update'
args = {
'map_id': map_data['id'],
'geojson': geojson,
'basemap': 'maphub-light',
'description': (
'Sample map for MapHub API tutorial:\n'
'[Create a map from a table CSV file](https://docs.maphub.net/tutorials/api_map_from_table/1_introduction.html)\n\n'
'Texts and images are from visitlondon.com'
),
'visibility': 'public',
}
headers = {'Authorization': 'Token ' + API_KEY}
res = requests.post(url, json=args, headers=headers)
data = res.json()
if 'id' not in data:
print(data['error'])
return
print('Map updated')
print(json.dumps(map_data, indent=2, ensure_ascii=False))
Full script file
Refresh image
Step 6: Refresh static image
Each MapHub map has a static image, which is used in the following places:
- Embed view, before the user clicks the “Play button”.
- The Download / Images links.
- Small thumbnails on “My Maps” page.
Images can be refreshed in two ways:
- Manually, when you save the map in the web interface.
- When using the API, by using the Refresh map image endpoint.
The following function refreshes the map’s image through the API.
def refresh_image():
with open(MAP_DATA_JSON) as f:
map_data = json.load(f)
url = 'https://maphub.net/api/1/map/refresh_image'
args = {
'map_id': map_data['id'],
}
headers = {'Authorization': 'Token ' + API_KEY}
res = requests.post(url, json=args, headers=headers)
data = res.json()
if 'id' not in data:
print(data['error'])
return
print(data['message'])