Static Maps API
The Static Maps API allows developers to create map images in their applications, providing a quick and easy way to display location data without the need for a full interactive map interface. With a simple HTTP request, users can generate maps with customizable markers, zoom levels, and map styles, making it an ideal solution for displaying location-based information on websites and mobile apps.
In addition, the Static Maps API lets you generate beautifully rendered high-resolution maps of any size for printing or inclusion in marketing materials.
Try the Static Maps API interactively on our playground:
Getting Started
The Static Maps API allows you to generate static map images based on specified parameters such as location, zoom level, size, and style. In addition, the API allows adding map markers and geometries.
The Static Maps API provides flexibility in how you request and customize your maps. You can use both HTTP GET and HTTP POST requests to tailor your map images.
Obtain Your API Key: To use the Static Maps API, you need to sign up for an API key. This key is used to authenticate your requests and track your usage. This page provides detailed instructions on how to generate an API key for Geoapify.
Use the Static Maps API Playground To simplify the process of creating URLs and generating the necessary code, you can use our Static Maps API Playground.
Use the API Reference: For a comprehensive list of parameters and detailed explanations, refer to the API Reference.
API Reference
Here is the Static Maps API URL form:
https://maps.geoapify.com/v1/staticmap?REQUEST_PARAMS
Request parameters
The Static Maps API uses the following parameters to define map images:
Param | Description | Example |
---|---|---|
apiKey | Geoapify API key | apiKey=c3da27885e3573e09e550d044bc55e22 |
style | One of the supported map styles | style=osm-bright |
width | Image width, in pixels, default is 1024. The maximal value is 4096; greater values are available on request. | width=800 |
height | Image height, in pixels, default is 768. The maximal value is 4096; greater values are available on request. | height=600 |
format | Image format, jpeg or png , default is jpeg as it is much faster for bigger map images. |
format=png |
area | Area to display currently supports only rectangular regions defined by two comma-separated pairs of longitude, latitude coordinates | area=rect:12.024,42.226,13.001,41.542 |
center | Coordinates of map center, currently supports a coordinate in form of longitude, latitude | center=lonlat:-74.044548,40.689252 |
zoom | Map zoom, only used in conjunction with "center", default is 17. Value ∈ [1..20] | zoom=14.5 |
pitch | View angle. Value ∈ [0..60] | pitch=18 |
bearing | Map rotation in degree. Value ∈ [0..360] | bearing=45 |
marker | Marker definition string, multiple markers are separated by pipe "|" character | marker=lonlat:-122.68573,45.51105;color:%23ff0000;size:medium |
scaleFactor | Map image scale factor. Value ∈ [1..2]; greater values are available on request | scaleFactor=2 |
geometry | Geometry definition string, multiple geometries are separated by pipe "|" character | geometry=circle:-74.04472450744129,40.69366453643252,50;linewidth:5 |
geojson | URL-encoded GeoJSON string with a max length of 1024 characters, the GeoJSON-feature properties linecolor, lineopacity, linewidth, linestyle (solid, dotted, dashed, longdash), fillcolor, fillopacity define visualization options. | |
styleCustomization | Allows to customize vector map layers with a |-separated format. The format is layer:color;size or layer:none , where layer is the name of the map layer, color is the desired color, size is the width or size, and none hides the layer. |
styleCustomization = background:%2383501d|water-pattern::%23971515|highway-primary:%232f955c;18|poi-level-2:none|poi-level-1:none |
lang | Map language | lang=el |
NOTE! You must specify one of the following parameters to define the map view: center, area, markers, geometry, or geojson. When the exact map view (center or area) information is missing, it's defined automatically to fit markers or geometries provided.
Note! Color values for markers, geometries, and style customization must be URL-encoded.
Marker definitions
You can add multiple markers to static maps. All marker definition parameters are joined with ";" character. Definitions of multiple markers are separated with "|" character.
The following parameters define a marker position and view:
Name | Description | Example |
---|---|---|
lonlat | Longitude and latitude coordinates of the marker | lonlat:-122.68573,45.51105 |
color | Marker color, named or in hex form. Note, # should be URL encoded as "%23". |
color:%23ff0000 |
type | Marker type, one of material , awesome , circle |
type:material |
size | Marker size, one of small , medium , large , x-large , xx-large |
size:x-large |
icon | Marker icon name (e.g icon:cloud) | icon:tree |
iconsize | Marker icon size - one of small , medium , large |
iconsize:medium |
icontype | Underlying icon font - one of awesome , material |
icontype:awesome |
text | Marker text to be used instead of icon | text:1 |
textsize | Marker text size, one of small , medium , large |
textsize:small |
whitecircle | Add white circle when painting icon or text, one of yes , no |
whitecircle:no |
shadow | Shadow presence and color - one of auto , no |
shadow:no |
shadowcolor | Color name or hex value; by default derived from marker color | shadowcolor:blue |
strokecolor | Marker outer line color; by name or hex value | strokecolor:%230077ff |
Here are examples of marker definitions:
Marker | Parameters |
---|---|
lonlat:-122.68573,45.51105;type:awesome;color:%231db510;size:x-large;icon:apple-alt;whitecircle:no |
|
lonlat:-122.68363,45.51081;type:circle;color:%23109db5;text:1;textsize:large;shadow:no |
|
lonlat:-122.68280,45.50998;type:material;color:%23d1d1d1;size:xx-large;icon:bus-alt;icontype:awesome;strokecolor:%23000000;shadow:no |
NOTE! The marker parameters string should be URL-encoded, especially ones containing "#" characters. You can use encodeURIComponent()
method to encode URL parameters in JavaScript.
Use Marker Icon API Playground to generate icons for map markers.
Geometry definitions
You can add multiple geometries to static maps. The geometry visualization parameters are joined with ";" character. Definitions of multiple geometries are separated with "|" character.
Below listed the geometry types and their visualization specification that are supported:
Circle
Parameter | Required? | Description | Example |
---|---|---|---|
circle:lon,lat,radius | REQUIRED |
The type of geometry, a circle's center and radius in pixels | circle:-74.044724,40.693664,50 |
linecolor:color | OPTIONAL |
Stroke color, URL-encoded color string value | linecolor:%23a577ff |
lineopacity:opacity | OPTIONAL |
Stroke opacity, takes values from 0 to 1 | lineopacity:0.3 |
linewidth:width | OPTIONAL |
Stroke line width in pixels | linewidth:3 |
linestyle:style | OPTIONAL |
Line style, takes values solid , dotted , dashed , longdash |
linestyle:dotted |
fillcolor:color | OPTIONAL |
Fill color, URL-encoded color string value | fillcolor:%23ffff00 |
fillopacity:opacity | OPTIONAL |
Fill opacity, takes values from 0 to 1 | fillopacity:0.3 |
Rect
Parameter | Required? | Description | Example |
---|---|---|---|
rect:lon1,lat1,lon2,lat2 | REQUIRED |
The type of geometry, a rect's nord-west and south-east points longitude and latitude coordinates | rect:-74.0447245,40.696645,-74.041724,40.692664 |
linecolor:color | OPTIONAL |
Stroke color, URL-encoded color string value | linecolor:%23a577ff |
lineopacity:opacity | OPTIONAL |
Stroke opacity, takes values from 0 to 1 | lineopacity:0.3 |
linewidth:width | OPTIONAL |
Stroke line width in pixels | linewidth:3 |
linestyle:style | OPTIONAL |
Line style, takes values solid , dotted , dashed , longdash |
linestyle:dotted |
fillcolor:color | OPTIONAL |
Fill color, URL-encoded color string value | fillcolor:%23ffff00 |
fillopacity:opacity | OPTIONAL |
Fill opacity, takes values from 0 to 1 | fillopacity:0.3 |
Polyline
Parameter | Required? | Description | Example |
---|---|---|---|
polyline:lon1,lat1,lon2,lat2,... | REQUIRED |
The type of geometry, a list longitude and latitude coordinates | polyline:13.410189,52.521661,13.412529,52.519263,13.407814,52.517903 |
linecolor:color | OPTIONAL |
Stroke color, URL-encoded color string value | linecolor:%23a577ff |
lineopacity:opacity | OPTIONAL |
Stroke opacity, takes values from 0 to 1 | lineopacity:0.3 |
linewidth:width | OPTIONAL |
Stroke line width in pixels | linewidth:3 |
linestyle:style | OPTIONAL |
Line style, takes values solid , dotted , dashed , longdash |
linestyle:dotted |
Polyline5
Parameter | Required? | Description | Example |
---|---|---|---|
polyline6:polyline-encoded |
REQUIRED |
Polyline encoded with 5 decimal places precision | polyline5:mRz}QjvGj~MfwO~~HryvA{nB~go@w~Obp... |
linecolor:color | OPTIONAL |
Stroke color, URL-encoded color string value | linecolor:%23a577ff |
lineopacity:opacity | OPTIONAL |
Stroke opacity, takes values from 0 to 1 | lineopacity:0.3 |
linewidth:width | OPTIONAL |
Stroke line width in pixels | linewidth:3 |
linestyle:style | OPTIONAL |
Line style, takes values solid , dotted , dashed , longdash |
linestyle:dotted |
Polyline6
Parameter | Required? | Description | Example |
---|---|---|---|
polyline6:polyline-encoded |
REQUIRED |
Polyline encoded with 6 decimal places precision | polyline6:k}n{nAnxoefDvdMkxs@b~YomRz}QjvGj~... |
linecolor:color | OPTIONAL |
Stroke color, URL-encoded color string value | linecolor:%23a577ff |
lineopacity:opacity | OPTIONAL |
Stroke opacity, takes values from 0 to 1 | lineopacity:0.3 |
linewidth:width | OPTIONAL |
Stroke line width in pixels | linewidth:3 |
linestyle:style | OPTIONAL |
Line style, takes values solid , dotted , dashed , longdash |
linestyle:dotted |
Polygon
Parameter | Required? | Description | Example |
---|---|---|---|
polygon:lon1,lat1,lon2,lat2,... | REQUIRED |
The type of geometry, a list longitude and latitude coordinates | polygon:13.410189,52.521661,13.412529,52.519263,13.407814,52.517903 |
linecolor:color | OPTIONAL |
Stroke color, URL-encoded color string value | linecolor:%23a577ff |
lineopacity:opacity | OPTIONAL |
Stroke opacity, takes values from 0 to 1 | lineopacity:0.3 |
linewidth:width | OPTIONAL |
Stroke line width in pixels | linewidth:3 |
linestyle:style | OPTIONAL |
Line style, takes values solid , dotted , dashed , longdash |
linestyle:dotted |
fillcolor:color | OPTIONAL |
Fill color, URL-encoded color string value | fillcolor:%23ffff00 |
fillopacity:opacity | OPTIONAL |
Fill opacity, takes values from 0 to 1 | fillopacity:0.3 |
GeoJSON geometry definitions
You can provide a GeoJSON as input to draw it on a map. Because URLs have a length limit, the maximum length of a URL-encoded GeoJSON string is 1,024 characters.
You can provide a Feature or FeatureCollection object as the GeoJSON. Each Feature object may have the following properties to define its appearance on the map:
Parameter | Description | Example |
---|---|---|
linecolor | Stroke color, URL-encoded color string value | "linecolor": "#a577ff" |
lineopacity | Stroke opacity, takes values from 0 to 1 | "lineopacity": 0.3 |
linewidth | Stroke line width in pixels | "linewidth": 3 |
linestyle | Line style, takes values solid , dotted , dashed , longdash |
"linestyle": "dotted" |
fillcolor | Fill color, URL-encoded color string value | "fillcolor": "#ffff00" |
fillopacity | Fill opacity, takes values from 0 to 1 | "fillopacity": 0.3 |
Below is a GeoJSON object example:
{
"properties": {
"fillcolor": "rgb(33,67,11)",
"fillopacity": 0.4
},
"geometry": {
"type": "Polygon",
"coordinates": [ [ [ 35, 10 ], [ 45, 45 ], [ 15, 40 ], [ 10, 20 ], [ 35, 10 ] ], [ [ 20, 30 ], [ 35, 35 ], [ 30, 20 ], [ 20, 30 ] ] ]
},
"type": "Feature"
}
The URL-encoded string for the GeoJSON above is:
geojson={"properties"%3A{"fillcolor"%3A"rgb(33%2C67%2C11)"%2C"fillopacity"%3A0.4}%2C"geometry"%3A{"type"%3A"Polygon"%2C"coordinates"%3A[[[35%2C10]%2C[45%2C45]%2C[15%2C40]%2C[10%2C20]%2C[35%2C10]]%2C[[20%2C30]%2C[35%2C35]%2C[30%2C20]%2C[20%2C30]]]}%2C"type"%3A"Feature"}
Map Style Customization
The Static Maps API allows you to customize the style of vector maps (all map styles except "osm-carto"). This powerful feature enables you to tailor the appearance of your maps to better fit your project's needs. Here are the customization options available:
- Hide Layers: You can choose to hide specific layers that you do not want to display on your map.
- Change Colors: Customize the colors for fill, line, and text layers to match your desired aesthetic.
- Change Line Width: Adjust the width of line layers to emphasize certain features or reduce visual clutter.
- Change Text Size: Modify the size of text layers to improve readability or fit your design.
The customization is done through the styleCustomization
parameter, which uses a |
-separated format to specify customizations for each layer. The format is as follows:
layer:color;size|layer:color;size|layer:none
Example Customizations
Change the Color and Size of Layers: To change the color of water bodies to blue with a size of 3, and to change the color of roads to grey with a size of 2:
styleCustomization=water:blue|roads:grey;20
Hide a Layer: To hide the buildings layer:
styleCustomization=buildings:none
Important Note
Color values for style customizations must be URL-encoded.
Interactive Playground
The list of available layers can vary depending on the chosen map style. To make the customization process easier, we provide an easy-to-use Playground. This interactive tool displays the available layers and allows you to edit them in a visual and intuitive way.
By leveraging these customization options, you can create highly personalized and visually appealing map images that perfectly match your project's requirements.
Embedding Static Map as Pictires to Website
You can easily link to a map relevant to your content by using an <img>
tag or with CSS background-image
ptoperty. In addition, you can add a map with the markup language. Here are code samples of adding static maps:
Using <img> tag
We recommend that you set the width and height of the image container and include the image's description in the "alt" property:
HTML
<img
width="600"
height="400"
src="https://maps.geoapify.com/v1/staticmap?style=toner-grey&width=600&height=400¢er=lonlat:-122.683237,45.510309&zoom=15.9318&apiKey=YOUR_API_KEY"
alt="Portland State University, 724 Southwest Hooker Street, Portland, OR 97201, United States of America"
>
As background-image
As the static maps are usually generated dynamically, you will probably want to specify styles as container properties:
HTML
<div
style="width:600px;height:400px;background-image:url(https://maps.geoapify.com/v1/staticmap?style=toner-grey&width=600&height=400¢er=lonlat:-122.683237,45.510309&zoom=15.9318&apiKey=YOUR_API_KEY);"
></div>
With the markdown language
As the API returned a JPG or PNG image, I can also add it with markdown language:
MD
![Portland State University, 724 Southwest Hooker Street, Portland, OR 97201, United States of America](https://maps.geoapify.com/v1/staticmap?style=toner-grey&width=600&height=400¢er=lonlat:-122.683237,45.510309&zoom=15.9318&apiKey=YOUR_API_KEY)
URL Examples
Here are API URL examples (click the URL to generate a static map):
Map with custom pitch and bearing
Double-resolution map
Map with markers
Map with geometries
Map with GeoJSON
Map with Customized Style
You can try more API options with Static Maps API Playground >>
HTTP Post Requests
The Static Maps API allows you to generate static map images by specifying parameters such as location, zoom level, size, and style. Typically, these parameters are defined in the URL when using HTTP GET requests. However, URLs have a maximum length of 2,048 characters, which limits the complexity of the map configurations you can create with HTTP GET requests.
To overcome this limitation and enable the creation of static maps with complex geometries, the Static Maps API also supports HTTP POST requests. With HTTP POST, you can include all the necessary parameters in the request body, allowing for much more detailed and intricate map customizations without the constraints of URL length.
Parameters Differences Between GET and POST Requests
The API has similar parameters for both HTTP GET and POST requests. However, some multi-value parameters in GET requests are split into separate parameters in POST requests. The table below lists the parameters that differ between the regular Static Map API (GET) and the POST request format:
Feature | GET Parameter | POST Parameters |
---|---|---|
Center | center=lonlat:coords |
center: [lon, lat] |
Area | area=type:coords |
area: [{type='rect', value{lon1, lat1, lon2, lat2}}] |
Markers | marker=lonlat;color;size;... |
markers: [{lon, lat, color, size, type, icon, iconsize, icontype, text, textsize,whitecircle, shadow, shadowcolor, strokecolor}] |
Geometries | geometry=type;fillcolor;linecolor;... |
geometries: [{type, value, linecolor, lineopacity, linewidth, linestyle, fillcolor, fillopacity}] |
Style Customization | styleCustomization |
styleCustomization: [{layer, color, size}] |
Detailed Description of geometries
Parameter for Static Maps API
The geometries
parameter allows you to add various geometric shapes to your static maps. This parameter supports multiple types of geometries, each with specific attributes for customization. Below is a detailed description of the supported geometries and their parameters.
- geometries: An array of geometry objects, each specifying the type and properties of the shape to be drawn on the map. This array can include any combination of the below geometry types.
General Geometry Attributes
All geometries share some common attributes for styling, which are defined in the joiGeometryBase
object:
- linecolor: The color of the line.
- lineopacity: The opacity of the line.
- linewidth: The width of the line.
- linestyle: The style of the line, which can be
solid
,dotted
,dashed
, orlongdash
. - fillcolor: The fill color for the shape.
- fillopacity: The opacity of the fill color.
Supported Geometry Types
Circle (
circle
){ "type": "circle", "linecolor": "#000000", "lineopacity": 1, "linewidth": 1, "linestyle": "solid", "fillcolor": "#000000", "fillopacity": 1, "value": { "lat": <latitude>, "lon": <longitude>, "radius": <radius> } }
- lat: Latitude of the circle's center.
- lon: Longitude of the circle's center.
- radius: Radius of the circle.
Rectangle (
rect
){ "type": "rect", "linecolor": "#000000", "lineopacity": 1, "linewidth": 1, "linestyle": "solid", "fillcolor": "#000000", "fillopacity": 1, "value": { "lat1": <latitude1>, "lon1": <longitude1>, "lat2": <latitude2>, "lon2": <longitude2> } }
- lat1: Latitude of the first corner.
- lon1: Longitude of the first corner.
- lat2: Latitude of the opposite corner.
- lon2: Longitude of the opposite corner.
Polyline (
polyline
){ "type": "polyline", "linecolor": "#000000", "lineopacity": 1, "linewidth": 1, "linestyle": "solid", "value": [ {"lat": <latitude1>, "lon": <longitude1>}, {"lat": <latitude2>, "lon": <longitude2>} ] }
- value: An array of coordinate objects, each with
lat
andlon
.
- value: An array of coordinate objects, each with
Polyline with Precision 5 (
polyline5
){ "type": "polyline5", "linecolor": "#000000", "lineopacity": 1, "linewidth": 1, "linestyle": "solid", "value": "<encoded_polyline>" }
- value: An encoded polyline string with precision 5.
Polyline with Precision 6 (
polyline6
){ "type": "polyline6", "linecolor": "#000000", "lineopacity": 1, "linewidth": 1, "linestyle": "solid", "value": "<encoded_polyline>" }
- value: An encoded polyline string with precision 6.
Polygon (
polygon
){ "type": "polygon", "linecolor": "#000000", "lineopacity": 1, "linewidth": 1, "linestyle": "solid", "fillcolor": "#000000", "fillopacity": 1, "value": [ {"lat": <latitude1>, "lon": <longitude1>}, {"lat": <latitude2>, "lon": <longitude2>} ] }
- value: An array of coordinate objects, each with
lat
andlon
.
- value: An array of coordinate objects, each with
Examples of Post Requests
Style customization and markers
Request Type: POST
URL: https://maps.geoapify.com/v1/staticmap?apiKey=YOUR_API_KEY
Request body:
{
"style": "osm-bright",
"scaleFactor": 2,
"width": 600,
"height": 400,
"center": {
"lat": 47.60948,
"lon": -122.336886
},
"zoom": 17.3926,
"pitch": 11.5,
"styleCustomization": [
{
"layer": "highway-minor-casing",
"color": "#2e5e39",
"size": 17
},
{
"layer": "place-other",
"color": "none"
}
],
"bearing": 58.4,
"markers": [
{
"lat": 47.60924165639446,
"lon": -122.33647609028213,
"color": "#ff0000",
"size": "medium"
}
]
}
Geometries
Request Type: POST
URL: https://maps.geoapify.com/v1/staticmap?apiKey=YOUR_API_KEY
Request body:
{
"style": "osm-bright",
"lang": "uk",
"width": 600,
"height": 400,
"geometries": [
{
"type": "rect",
"fillcolor": "#ff9976",
"fillopacity": 0.6,
"linewidth": 5,
"linecolor": "red",
"value": {
"lat1": 48,
"lon1": 12,
"lat2": 48.5,
"lon2": 12.5
}
}
]
}
Attribution
Map style Attributions
By default, Static Maps API adds map style attributions into the right bottom corner of the map image. But you need to care about attributions yourself when you hide the automatically added attribution.
The following attributions are required:
1. Geoapify attribution
The Free Pricing Plan requires the Geoapify attribution. The correct Geoapify attribution is:
Powered by <a href="https://www.geoapify.com/">Geoapify</a>
Geoapify paid packages include the "White label" option. So no Geoapify attribution is needed when you subscribed to Geoapify.
2. OpenStreetMap attribution
The Geoapify server generates place tiles based on OpenStreetMap data, which is licensed under ODbL 1.0. Using this service will require proper attribution:
<a href="https://www.openstreetmap.org/copyright" target="_blank">© OpenStreetMap contributors</a>
Learn more
3. OpenMapTiles attribution
We use the OpenMapTiles schema to generate map tiles (except the osm-carto map style). It requires the following attribution:
<a href="http://openmaptiles.org/" target="_blank">© OpenMapTiles</a>
Icon library attribution
You need to add an attribution to Font Awesome when you add Font Awesome map markers generated with Map Markers API. The Font Awesome icons are distributed under SIL OFL 1.1 license.
Learn more
Where to put it?
This credit needs to appear in a place that would be appropriate for the medium or means you are using. For example:
- For interactive maps and map pictures, the credit should typically appear in the corner of the map, as commonly seen with map APIs/libraries such as Leaflet, MapLibre, OpenLayers;
- For printed maps, the credit should appear beside a map if that's where other such credits appear, and/or in "acknowledgments" section of the publication.
Pricing
We calculate the cost for Geoapify API calls in credits. Credits help us make our Pricing Plans flexible, universal, and simple to understand.
We offer a Free pricing plan with 3,000 credits per day. Start using our API for free and with no commitment. When you need more than the free plan offers, subscribe to one of our paid plans.
We use the following rules to calculate your Static Maps API usage fee:
Rule | Cost in credits | Example |
---|---|---|
Request cost | 1 static map request cost is 1 credit | |
Map tiles cost | NUMBER_OF_MAP_TILES / 4 | The 1200x600px is about 15-20 map tiles, which is 4-5 credits |
Map Markers cost | 1 map marker is 1 credit | A map with 4 markers costs additional 4 credits |
Examples
An 800x600 px map with six markers cost 1 + (800*600)/(256*256)/4 + 6 = 1 + 2 + 6 = 9 credits.
Note! More tiles are needed when you use a perspective view for a map. Therefore, the number of tiles will increase.