Create static maps using the REST API
Several examples of using the Static Maps function.
The sample code in the example is always inserted into <img src=”https://api.mapy.cz/v1/static/map?…”> and the page directly displays the result.
Simple Tourist Map
The tourist map is centered on the middle of Špindlerův Mlýn, with a requested zoom of 16 and image size of 300x200px.
https://api.mapy.cz/v1/static/map?lon=15.608&lat=50.725&zoom=16&width=300&height=200&mapset=outdoor&apikey=YourApiKey
Aerial Map with a Marker
We change the map to aerial and add one marker.
https://api.mapy.cz/v1/static/map?lon=15.608&lat=50.725&zoom=16&width=300&height=200&mapset=aerial&markers=color:red;size:normal;15.6081,50.7250&apikey=YourApiKey
Winter Map with Three Markers – Bestfit
In this example, we add 3 markers to the map. We do not use lat, lon, or zoom – the area will automatically adjust to ensure the markers are visible.
https://api.mapy.cz/v1/static/map?width=300&height=200&mapset=winter&markers=color:red;size:normal;label:A;15.6051,50.7270&markers=color:green;size:normal;label:B;15.6111,50.7230&markers=color:blue;size:normal;label:C;15.6031,50.7220&apikey=YourApiKey
Using a Bounding Box
In this case, we specify lat, lon twice (and do not provide zoom). This determines the bounding box, or the area that should be displayed on the map. In this case, for the whole Czech Republic.
https://api.mapy.cz/v1/static/map?lon=12.09&lat=48.55&lon=18.87&lat=51.05&width=300&height=200&mapset=basic&apikey=YourApiKey
Scale 1 vs 2
Two identical images, the second with retina resolution (scale 2).
https://api.mapy.cz/v1/static/map?lon=15.742&lat=50.735&zoom=14&width=200&height=200&scale=1&mapset=outdoor&markers=color:red;size:normal;label:1;15.742,50.735&apikey=YourApiKey
https://api.mapy.cz/v1/static/map?lon=15.742&lat=50.735&zoom=14&width=200&height=200&scale=2&mapset=outdoor&markers=color:red;size:normal;label:1;15.742,50.735&apikey=YourApiKey
Using shapes
We draw a rectangle using path and a triangle using polygon.
https://api.mapy.cz/v1/static/map?width=500&height=450&mapset=aerial&shapes=color:red;path:[(15.6054,50.7260;15.6074,50.7260;15.6074,50.7240;15.6054,50.7240;15.6054,50.7260)]&shapes=color:blue;fill:%230000FF80;polygon:[(15.6112,50.7255;15.6132,50.7250;15.6152,50.7255;15.6112,50.7255)]&apikey=eyJpIjoyNTcsImMiOjE2Njc0ODU2MjN9.c_UlvdpHGTI_Jb-TNMYlDYuIkCLJaUpi911RdlwPsAY