English version was created automatically using Drupal module auto_node_translate and free DeepL translator.

Migration from Mapy.cz JS SDK to new REST API Mapy.cz

zveřejněno 2025-02-11

Embedding maps on websites is very common. You may have noticed somewhere that embedded List maps display a warning to developers about an unsupported old library. In this case you need to switch to the new REST API of Mapy.cz

Relates to the article How to display your own waypoints and markers on a tourist map from Seznam?

A common solution to display maps on websites is to use "list" maps, i.e. Mapy.cz. They used to offer their interface for free using the Mapy.cz SDK javascript library, which stopped being supported at the beginning of 2024 and will be discontinued completely by the end of 2025 (https://developer.mapy.cz/js-api/).

List offers a new solution, the Mapy.cz REST API. It is therefore necessary to migrate the solution (code), otherwise the maps will stop working completely after some time. In the meantime, there is now (February 2025) a warning for developers.

upozorneni

The new interface tracks API usage for your project and charges so-called credits for each usage. These are free in some limited amount (250,000) and should be plenty for normal work. Under certain conditions you can get up to 10,000,000 for free, which should really be enough for most common cases already. Credits can of course be purchased if needed.

  • Basic plan - 250,000 free credits
  • Concessionary plan - 10,000,000 free credits
  • Price for higher consumption per 1,000 credits : 1.60 CZK

https://developer.mapy.cz/cena/

 

Basic documentation on how to implement the new maps is available on the list site https://developer.mapy.cz/rest-api/mapove-knihovny/. Here you can see that different javascript libraries can be selected to display the map backgrounds themselves. The simplest and recommended one to start with is the Leaflet library. Others offered are OpenLayers, MapLibre or Cesium JS.

The basics are to have an account with Seznam, log into it and then go to the map portal https://developer.mapy.cz/account/. It is then easy to create a new project for your application or website, automatically generating a unique API key that is required for identification. Of course, it is very important to remember to secure this API key properly! https://developer.mapy.en/portal-muj-ucet/secure-api key/

moje projekty
přehled projektu
detail spotřeby
finanční nastavení

 

Basic tutorials are available here https://developer.mapy.cz/rest-api/tutorials/showing-basic-maps/. You don't need a server to test the maps, just create an HTML file and open it in a browser.

 

A real example

What we will show in this example:

  • Implementation using the Leaflet library https://leafletjs.com/
  • Setting up layers - displaying the base and aerial map
  • Displaying the ruler/scale (Scale)
  • Creating two different types of markers (Marker) with different image (Icon) and with popup a bubble with HTML code (bindPopup)
  • Put them into groups (featureGroup)
  • Automatically zoom in on selected markers

 

Ukázka Mapy.cz REST API
Ukázka Mapy.cz REST API

Sample Code

download sample file