If you need a static non-zoomable image of a map for your web or graphic design, you can generate it using one of the pre-defined styles or with your own design. Sign in to MapTiler Cloud, select one of the maps, and scroll down. There is a button Generator for static maps in the last section Static map as an image. Here you can generate your own map with a graphical static maps generator or use it as an API for your own application.
Visual generator
The visual generator is very simple: you just set the size of an image, optionally check the self-explaining Double resolution (for retina displays), and zoom to the selected area.
Below there are two clickable links, which are automatically updating while you are changing the parameters of your request, but they should give you the same image if you click on them.
The maximal resolution for an image is currently set to 2048x2048 px or 1024x1024 px for retina displays (x2).
Visual generator for static maps. This particular image will include only the area in the black box: city center of Athens and its harbor Piraeus
API description
If you want to build your own application, there are two basic options of how to define the area of your interest. The first one is called a Center-based URL, where the area displayed on an image is defined by the longitude and latitude of the image’s center point and image resolution. The other option, Bounds-based URL, is defined by a couple of coordinates defining the bottom left and top right corner.
Autofitting the area
It is also possible to use auto
instead of the region specification (center or bounds) in the URL. In such a case, the area will be automatically calculated based on a path from the query (at least one polygon or marker has to be specified). See the documentation of the format and possible values below.
Zoom level calculation
When requesting a Static Maps API for a specific area (bounds-based or autofitted), the resulting image positioning is always rounded to the nearest lower zoom level so that all the labels and potential raster images (for satellite maps) are sharp and not re-scaled.
Example: Let's say we calculate that for the given bounds, the zoom level 9.5 would be ideal, but we don't want to create "ugly" pixelated images (the Static Maps are "stitched" from rasterized tiles for optimal performance), so we can use either z9 or z10. We always use the lower zoom level to ensure that the whole bounds are visible.
Adding polygons and lines
The polygon or polyline can be passed in a path
query parameter (it can be used more than once). Coordinates of the individual path vertices are comma-separated lng,lat
pairs. The vertices are separated with a pipe symbol. Additionally, these following special "commands" can be used (in a form of key:value
appended before the path coordinates):
-
fill
- color to use as the fill (e.g.red
,rgba(255,255,255,0.5)
,#0000ff
,none
,false
) -
stroke
- the color of the path stroke -
width
- width of the stroke (in pixels) -
enc
- Path encoded according to Google Encoded Polyline Format-
e.g.
_p~iF~ps|U_ulLnnqC_mqNvxq`@
-
If used, do not specify the coordinate pairs -- the rest of this
path
parameter is considered to be part of the encoded polyline string.
-
You can also use fill
, stroke
and width
as a separate query parameters to specify default styling for all the paths.
Examples:
-
path=5.9,45.8|5.9,47.8|10.5,47.8|10.5,45.8|5.9,45.8
-
a polygon with default colors
-
-
path=stroke:green|width:3|fill:none|5.9,45.8|5.9,47.8|10.5,47.8|10.5,45.8|5.9,45.8
-
the same polygon, but with 3px green stroke a no fill
-
-
path=stroke:red|fill:none|enc:_p~iF~ps|U_ulLnnqC_mqNvxq`@
-
draws a red line based on the encoded polyline
-
Adding markers
The markers can be passed in a markers
query parameter (it can be used more than once). Each marker is a comma-separated lng,lat
pair. Individual markers are separated with a pipe symbol. Each marker can also have a different color - specified as the 3rd parameter (e.g. 14.4,50.1,red|8.6,47.4,blue
). Additionally, these following special "commands" can be used (in a form of key:value
appended before the marker coordinates):
-
icon
- URL to a remote image (URL-encoded)-
You can use a URL shortener service to create more compact queries.
-
Icon has to be at most 64 kB and 4096 pixels (e.g. 64x64 image).
-
If used, the specified colors of the markers are ignored.
-
-
anchor
- the anchor point of the custom icon, possible values:-
top, left, bottom, right, center, topleft, bottomleft, topright, bottomright
-
the default value is
bottom
-
-
scale
- the scale of the image (useful if you want to provide a HiDPI image that scales down correctly), the default value is1
Examples:
-
markers=14.4,50.1|8.6,47.4|2.4,48.9
- 3 separate markers will be displayed -
markers=14.4,50.1,red|8.6,47.4,blue
- 1 red and 1 blue marker -
markers=icon:https://tinyurl.com/yakrjl3t|anchor:center|14.4,50.1|8.6,47.4
-
2 markers with the specified custom icon centered at their positions
-
Other
-
attribution
-
change the location of the attribution text:
topleft, bottomleft, topright, bottomright
-
attribution=false
orattribution=0
to disable attribution (make sure to display the correct attribution yourself in case you use this)
-
-
latlng
(latlng=true
orlatlng=1
) - indicates the polygon and marker coordinates are inlat,lng
order rather than the usuallng,lat
-
padding
- “percentage” padding for fitted endpoints (bounds-based and auto)-
e.g. value of
0.1
means “add 10% size to each side to make sure the area of interest is nicely visible”
-
Note: in the first part of 2019, we started to operate with 512-based zoom level numbering by default. This primarily changes the tile numbering (512x512 tiles are now "default"), but it also affects this Static maps endpoint (only the center-based variant). If you are using this endpoint, you have to shift the zoom level when changing the domain.
Comments
0 comments
Please sign in to leave a comment.