
Marker Icon API: Custom Map Markers as PNG
Generate markers as PNG from a URL for Leaflet, MapLibre, Google Maps and OpenLayers
Map Marker Icon API lets you create fully customizable map marker icons using simple URL parameters. Generate PNG marker images with custom colors, sizes, text or icon content, and more — no design skills needed.
Use the generated icons in Leaflet, MapLibre GL, Google Maps, OpenLayers, or embed them into static images with the Static Maps API. Whether you're building a POI map, store locator, or delivery dashboard, the API helps you create clean, branded visuals.
Choose icons from Material, Material Symbols, Font Awesome, Lucide, Tabler, Phosphor or Material Design Icons, pick one of 9 shapes, and add outlines and shadows. Every response tells you the marker's size and anchor point. Use icons via URL or download them — attribution is required on the free plan.
On this page
Features and Capabilities
Customizable Marker Styles
The Map Marker Icon API lets you choose from multiple marker styles to match your map’s purpose and design. Available styles include:
- Material Design (
type=material, default) — a clean, modern pin-style icon - Font Awesome (
type=awesome) — shaped like the classic map marker - Circle (
type=circle) — simple, round map marker icons ideal for category or status indicators - Plain (
type=plain) — displays icon or text without any background shape - Library pins (
type=tabler,phosphor,lucide,material-symbols,material-symbols-rounded) — the map-pin shape of that icon library, so the pin matches the icons inside it
You can fully customize each marker with background color (color), content color (contentColor), outline (strokeColor, strokeWidth), and shadow (shadowType, shadowColor). This flexibility helps you create consistent, branded map marker PNGs for any use case.
Outlines and Shadow Styles
Two parameters change how a marker stands out from the map:
strokeWidthadds an opaque outline from0to10CSS pixels, at mostsize / 6. The outline is drawn outside the shape, and the shape shrinks so the marker keeps itssize. Set its color withstrokeColor. WithoutstrokeWidth, the marker gets a thin semi-transparent outline.shadowTypeselects the shadow:ellipse(the default ground shadow),ellipse-dark,ellipse-soft,floating(a detached shadow that makes the marker look lifted),drop(a blurred shadow under the whole shape), orglow(a blurred halo).shadowColorsets its color, andnoShadowremoves it. Circle markers have no shadow unless you setshadowType.
Example (Phosphor pin with a green glow):
https://api.geoapify.com/v2/icon/?type=phosphor&icon=tree&color=%232e7d32&shadowType=glow&shadowColor=%232e7d32&size=64&contentSize=26&scaleFactor=2&apiKey=YOUR_API_KEYThe shadow is part of the PNG, so it changes the image size and the position of the pin tip. The size and anchor headers tell you both.
Icon or Text Content
Use either an icon or text as the marker’s inner content:
- Display symbols from one of seven icon libraries, selected with
iconType:- Material Icons (
material) - Material Symbols, Outlined and Rounded (
material-symbols,material-symbols-rounded) - Font Awesome 6 Free (
awesome) - Lucide (
lucide) - Tabler Icons (
tabler) - Phosphor Icons (
phosphor) - Material Design Icons by Pictogrammers (
mdi)
- Material Icons (
- Or replace the icon with a single character or number using the
textparameter
When you omit iconType, the library follows the shape: material for material, circle and plain markers, awesome for awesome markers, and the library of the same name for the library pins. You can also mix them, for example a Font Awesome pin with a Material Design Icons bicycle: type=awesome&iconType=mdi&icon=bicycle.
You can also control the inner content size (contentSize) and color (contentColor) independently from the background.
Custom Icon Size and Content Size
You can control the overall size of the map marker icon using the size parameter, which sets the height of the marker shape in pixels, without the shadow. Additionally, the contentSize parameter lets you independently adjust the size of the icon or text displayed inside the marker. The default contentSize doesn't grow with size, so set both for larger markers.
This gives you full control over the proportions of the marker — whether you want a compact icon for dense maps or a large, eye-catching marker for key locations.
Example:
size=64makes the marker shape 64 pixels high (the shadow adds a few pixels to the image)contentSize=32makes the inner icon 32 pixels tall
This flexibility allows you to match different zoom levels, styles, and device resolutions with precision.
Dynamic URL-Based Generation
No build process or image editor needed — just construct a URL with the desired parameters. The API returns a ready-to-use marker PNG. You can use icons dynamically in your app or save them locally for reuse.
Example URL:
https://api.geoapify.com/v2/icon/?type=material&color=%23ffd150&size=80&icon=landmark&iconType=awesome&contentSize=28&contentColor=%234f4f4f&apiKey=YOUR_API_KEYRetina-Ready PNG Output
The Map Marker Icon API generates high-quality PNG images, optimized for both standard and high-resolution (retina) displays. To create retina-ready icons, simply add the scaleFactor=2 parameter to your API request.
This ensures that your map marker PNGs look sharp and crisp on all screens — whether they’re used in a web app, mobile app, or desktop interface.
Example (2× retina icon):
https://api.geoapify.com/v2/icon/?type=awesome&color=%23ff5050&size=80&icon=paw&contentSize=35&contentColor=%23294685&scaleFactor=2&apiKey=YOUR_API_KEYYou can use these icons directly via URL or download and embed them into your application — ideal for modern, pixel-perfect maps.
Works with All Major Map Libraries
The Map Marker Icon API is compatible with all popular JavaScript mapping libraries. You can use the generated map marker PNGs directly as custom icons:
- Leaflet – Use
L.icon()andL.marker()to display custom icons. - MapLibre GL – Create an HTML element and use it with
new maplibregl.Marker(). - Google Maps – Pass an
<img>with the PNG as thecontentof anAdvancedMarkerElement. - OpenLayers – Use
ol.style.Iconfor adding custom image markers to vector layers.
Every response returns the marker's display size and anchor point, so you place each map marker icon exactly, without measuring the image.
Size and Anchor in Response Headers
The PNG includes the marker's shadow, so the pin tip is not at the bottom edge of the image, and the image grows with shadows such as drop or glow. Instead of guessing, read these response headers:
| Header | Meaning |
|---|---|
Icon-Width, Icon-Height | Display size in CSS pixels, including the shadow (the PNG size divided by scaleFactor) |
Icon-Anchor-X, Icon-Anchor-Y | The point that touches the map location, measured from the top-left corner: the pin tip for pins, the center for circles without a shadow |
Icon-Marker-Style | The same marker as Static Maps API marker options, so you can draw it on a static map too |
A HEAD request with the same parameters returns only the headers, without the image:
curl -I "https://api.geoapify.com/v2/icon/?type=awesome&size=60&scaleFactor=2&apiKey=YOUR_API_KEY"For this marker the headers return Icon-Width: 46, Icon-Height: 67, Icon-Anchor-X: 23, and Icon-Anchor-Y: 60.52: display the PNG at 46 × 67 px and put the point 23 px from the left and 60.52 px from the top on the location. The values depend on the shape parameters (type, size, strokeWidth, shadowType, scaleFactor), not on the icon or color, so one request per marker style is enough. The headers are exposed through CORS, so browser code can read them with fetch().
See Shadows and map placement in the documentation for the sizes of every shape and shadow style.
Free to Use with Attribution
You can use the Map Marker Icon API for free under the Geoapify Free Plan — all you need to do is include proper attribution. The generated map marker PNGs can be used directly via URL or downloaded and included in your projects without any additional restrictions from Geoapify.
The icons are based on open-source libraries and come with the following attribution requirements:
-
Geoapify Attribution: If you're on the Free Plan (3,000 credits per day; 1 icon request = 1 credit), you must display
The map marker icons are generated with Geoapify.Paid plans with the White Label option remove this requirement. -
Font Awesome Attribution
If you use Font Awesome icons (iconType=awesome) or the Font Awesome pin shape (type=awesome, based on the Font Awesome location-dot icon), attribution to Font Awesome is required: Font Awesome Free icons are licensed under CC BY 4.0, the fonts under the SIL OFL 1.1. See the Font Awesome Free license. -
Material Design Attribution
Material icons are licensed under the Apache License 2.0 and do not require attribution. -
Material Symbols Attribution: Material Symbols (
iconType=material-symbols,material-symbols-rounded, and the pins of the same names) are licensed under the Apache License 2.0 and do not require attribution. -
Lucide, Tabler, Phosphor and Material Design Icons: Lucide (ISC), Tabler Icons (MIT), Phosphor Icons (MIT) and Material Design Icons (Pictogrammers Free License) don't require visible attribution on your map. If you redistribute the icon files, keep the library's license notice.
This means you can generate icons dynamically or download and bundle them with your app — even on the free plan — as long as the attribution terms are followed.
You can find the full list of available features, customization options, and parameter details in the Map Marker Icon API documentation →
Consistent Marker Icon Sets
A map with several place categories reads best when every marker has the same shape and size, and only the symbol and color change. With the Marker Icon API, that's one URL template: keep type, size, contentSize and scaleFactor fixed, and set icon and color per category.
All five markers above come from this template, with size=60 and scaleFactor=2:
https://api.geoapify.com/v2/icon/?type=awesome&color={color}&size=60&icon={icon}&contentSize=24&contentColor=%23ffffff&noWhiteCircle&scaleFactor=2&apiKey=YOUR_API_KEY| Category | icon | color |
|---|---|---|
| Cafe | mug-saucer | %23c0732e |
| Museum | landmark | %237b5cd6 |
| Park | tree | %2339a845 |
| Pharmacy | prescription-bottle-medical | %23e04f5f |
| Hotel | bed | %232f7bd9 |
Because every marker in the set has the same size (46 × 67 px, displayed at 2× resolution), one anchor setting works for all of them in your map library. You can request the set once, store the markers PNG files with your app and serve them yourself: stored icons have no usage limits from Geoapify.
For a full walkthrough with Places API data, Leaflet and MapLibre GL, see the how-to Build a Consistent Marker Icon Set for Place Categories.
Code Examples: Using Marker PNGs in Map Libraries
Pin markers have a ground shadow by default, and the shadow is part of the PNG. Its size depends on the shape, the size and the shadowType, so the pin tip sits a few pixels above the bottom edge of the image. Take the display size and the anchor from the Icon-* response headers and pass them to your map library:
- In Leaflet, set
iconSizeto[Icon-Width, Icon-Height]andiconAnchorto[Icon-Anchor-X, Icon-Anchor-Y]. - In MapLibre GL or Mapbox GL, size the marker element to
Icon-Width×Icon-Heightand useanchor: "top-left"withoffset: [-Icon-Anchor-X, -Icon-Anchor-Y]. - In Google Maps, set
anchorLeftandanchorTopon theAdvancedMarkerElementso the pin tip, not the image corner, sits on the coordinate. - In OpenLayers, set
anchorinol.style.Icon(in image pixels, or as fractions of the image size).
You can preview your marker icons in the Marker Icon Playground, which also shows the image dimensions and the shadow offset.
For step-by-step walkthroughs, see the how-tos Add Custom Marker Icons to Leaflet, MapLibre GL, and OpenLayers Maps and Add Markers to a Map. Ready-to-run examples that read the headers with a HEAD request and switch shapes and shadow styles are available for Leaflet, MapLibre GL, and OpenLayers.
If you prefer a flat icon with no shadow, add the noShadow parameter to your API request. A pin without a shadow is exactly size pixels high, and its anchor is at the bottom center:
https://api.geoapify.com/v2/icon/?type=awesome&color=%23ff50bb&size=40&icon=tree&contentSize=18&contentColor=%2334811a&noShadow&noWhiteCircle&scaleFactor=2&apiKey=YOUR_API_KEYNow let’s look at examples for using map marker PNGs in each of the most popular mapping libraries.
Leaflet Custom Marker
To use a custom map marker in Leaflet, generate the icon with the Geoapify Marker Icon API and assign it using L.icon(). Leaflet allows you to control how the icon is positioned on the map with iconAnchor and how popups are displayed with popupAnchor.
In this example:
size=60in the URL defines the marker height without shadow.- For this URL, the response headers return
Icon-Width: 46,Icon-Height: 67,Icon-Anchor-X: 23, andIcon-Anchor-Y: 60.52. iconSize: [46, 67]matches the display size (width × height).iconAnchor: [23, 60.5]places the tip of the pin, above the shadow, on the coordinate.popupAnchor: [0, -62]makes the popup open just above the top of the icon.
The marker uses a Font Awesome "paw" icon, custom background and icon colors, and is retina-ready via scaleFactor=2.
const markerIcon = L.icon({
iconUrl: `https://api.geoapify.com/v2/icon/?type=awesome&color=%23ffc3e8&size=60&icon=paw&contentSize=29&contentColor=%2334811a&noWhiteCircle&scaleFactor=2&apiKey=${myAPIKey}`,
iconSize: [46, 67],
iconAnchor: [23, 60.5], // Icon-Anchor-X, Icon-Anchor-Y
popupAnchor: [0, -62]
});
const zooMarkerPopup = L.popup().setContent("This is Munich Zoo");
const zooMarker = L.marker([48.096980, 11.555466], {
icon: markerIcon
}).addTo(map).bindPopup(zooMarkerPopup);Try this example live on JSFiddle →
MapLibre GL Custom Marker
This example demonstrates how to add a custom marker generated by the Geoapify Marker Icon API using a DOM element. The icon includes a shadow, and the popup is positioned above the visible part of the marker.
In this case:
size=60in the URL defines the height of the icon (excluding shadow).- For this URL, the headers return a 46 × 67 px marker with the anchor at 23, 60.52; the shadow takes the bottom part of the image.
iconWidthandiconHeightWithShadowareIcon-WidthandIcon-Height, andanchorYisIcon-Anchor-Y.- With
anchor: 'bottom', the marker is moved down by the space below the pin tip (Icon-Height - Icon-Anchor-Y, about6.5pxhere) so the tip sits on the coordinate. For other styles, useanchor: 'top-left'withoffset: [-Icon-Anchor-X, -Icon-Anchor-Y]. - The popup is offset to appear just above the actual icon (ignoring the shadow area).
const markerIconSize = {
iconWidth: 46,
iconHeight: 60,
iconHeightWithShadow: 67,
anchorY: 60.5, // Icon-Anchor-Y
}
const el = document.createElement('div');
el.className = 'marker';
el.style.backgroundImage = `url(https://api.geoapify.com/v2/icon/?type=awesome&color=%23c3e2ff&size=60&icon=monument&contentSize=25&contentColor=%232b2b2b&noWhiteCircle&scaleFactor=2&apiKey=${myAPIKey})`;
el.style.backgroundSize = 'contain';
el.style.backgroundRepeat = 'no-repeat';
el.style.width = `${markerIconSize.iconWidth}px`;
el.style.height = `${markerIconSize.iconHeightWithShadow}px`;
new maplibregl.Marker({
element: el,
anchor: 'bottom',
offset: [0, markerIconSize.iconHeightWithShadow - markerIconSize.anchorY]
})
.setLngLat(pinCoords)
.setPopup(
new maplibregl.Popup({
offset: { bottom: [0, -markerIconSize.iconHeight] }
}).setHTML("Statue of Liberty")
)
.addTo(map);Try this example live on JSFiddle →
Google Maps Custom Marker (AdvancedMarkerElement)
This example shows how to use a Geoapify Marker Icon with the newer AdvancedMarkerElement from the Google Maps JavaScript API. We use a retina PNG marker, align it to the map coordinate, and show a popup on click.
- The marker icon has a defined size of
60pxin the URL; the headers return a 46 × 67 px image with the anchor at 23, 60.52. - We set
anchorTop: "-60px"(about-Icon-Anchor-Y) so the pin tip, rather than the shadow below it, aligns with the map coordinate. - The popup (
InfoWindow) is offset by-60pxto appear above the visible icon.
const { Map } = await google.maps.importLibrary("maps");
const { AdvancedMarkerElement } = await google.maps.importLibrary("marker");
const myAPIKey = "YOUR_API_KEY";
const map = new Map(document.getElementById("map"), {
zoom: 10,
center: { lat: 51.5073371, lng: -0.1276495 }, // London
mapId: "DEMO_MAP_ID", // use your own map ID in production
});
const customMarkerIcon = document.createElement("img");
customMarkerIcon.src = `https://api.geoapify.com/v2/icon/?type=awesome&color=%23c3e2ff&size=60&icon=monument&contentSize=25&contentColor=%232b2b2b&noWhiteCircle&scaleFactor=2&apiKey=${myAPIKey}`;
customMarkerIcon.style.width = "46px";
customMarkerIcon.style.height = "67px";
const customMarker = new AdvancedMarkerElement({
map,
position: { lat: 51.5073371, lng: -0.1276495 },
content: customMarkerIcon,
anchorTop: "-60px",
title: "A marker using a custom PNG image",
});
const infoWindow = new google.maps.InfoWindow({
content: "City of London",
pixelOffset: new google.maps.Size(0, -60), // move popup above icon
});
customMarkerIcon.addEventListener("click", () => {
infoWindow.open({
anchor: customMarker,
map,
});
});This approach ensures the marker aligns precisely and remains visually crisp on retina displays.
OpenLayers Custom Marker
This example shows how to add a custom map marker PNG to OpenLayers using the Geoapify Marker Icon API, and position a popup above it.
- The marker icon size is set to
60in the API URL. - For this URL, the headers return a 46 × 67 px marker with
Icon-Anchor-Y: 60.52. - The
anchoraligns the pin tip, above the shadow, as fractions of the image size:anchor: [0.5, 60.5 / 67] - The popup is positioned 8px above the icon top:
offset: [0, -(60 + 8)]
const markerCoords = ol.proj.fromLonLat([2.2945, 48.85825]); // Eiffel Tower
const marker = new ol.Feature({
geometry: new ol.geom.Point(markerCoords),
name: 'Eiffel Tower',
});
marker.setStyle(new ol.style.Style({
image: new ol.style.Icon({
src: `https://api.geoapify.com/v2/icon/?type=awesome&color=%23fcd3b2&size=60&icon=monument&contentSize=25&contentColor=%232b2b2b&noWhiteCircle&scaleFactor=2&apiKey=${myAPIKey}`,
width: 46,
height: 67, // PNG image size: width × height
anchor: [0.5, 60.5 / 67], // Icon-Anchor-Y / Icon-Height
anchorXUnits: 'fraction',
anchorYUnits: 'fraction'
})
}));
const vectorLayer = new ol.layer.Vector({
source: new ol.source.Vector({
features: [marker],
}),
});
map.addLayer(vectorLayer);
// Create popup element
const popupElement = document.createElement('div');
popupElement.className = 'ol-popup';
popupElement.innerHTML = 'Eiffel Tower';
document.body.appendChild(popupElement);
const overlay = new ol.Overlay({
element: popupElement,
positioning: 'bottom-center',
stopEvent: false,
offset: [0, -(60 + 8 /* tooltip size */ )], // move above the marker
});
map.addOverlay(overlay);
// Show popup on click
map.on('click', function (event) {
map.forEachFeatureAtPixel(event.pixel, function (feature) {
if (feature === marker) {
overlay.setPosition(markerCoords);
}
});
});Try it on JSFiddle →
Guides
These guides show how to use marker PNGs from the Marker Icon API on interactive maps, with ready-to-run examples.
Put markers on a map
Add marker PNGs to Leaflet, MapLibre GL and OpenLayers maps.
- Add markers to a mapBeginner10 min
- Add custom marker icons and place them with the anchor headersBeginner15 min
- Build a consistent marker icon set for place categoriesIntermediate15 min
Pricing and Licensing
The Map Marker Icon API is built on top of open-source icon libraries — Material Icons and Material Symbols, Font Awesome, Lucide, Tabler, Phosphor, and Material Design Icons — and we follow the same spirit of openness.
You can use the API in two ways:
-
Dynamic Use with API Key (Cloud Access)
- Use icon URLs dynamically by including your Geoapify API key.
- The Free plan includes 3,000 credits per day; each icon request costs 1 credit.
- View pricing and upgrade options →
-
Generate Once, Host Yourself
- You may generate marker icons using the API and store them locally in your app or website — with no usage limits from Geoapify.
Attribution Requirements
If you use the API on the Free plan, you must include the following attribution:
"The map marker icons are generated with Geoapify"
Additionally, when you use icons from third-party libraries:
-
- Font Awesome Free icons are licensed under CC BY 4.0, the fonts under the SIL Open Font License 1.1
- Attribution to Font Awesome is required when your markers use Font Awesome icons (
iconType=awesome) or the Font Awesome pin shape (type=awesome, based on the Font Awesome location-dot icon)
-
- Licensed under the Apache License 2.0
- No attribution is required for Material Icons when used under that license
-
- Licensed under the Apache License 2.0; no attribution is required
-
- Licensed under the ISC License
- No attribution is required, but including a credit such as “Icons by Lucide” is appreciated, especially for open-source or educational projects.
-
Tabler Icons, Phosphor Icons and Material Design Icons
- Licensed under the MIT License (Tabler), the MIT License (Phosphor), and the Pictogrammers Free License (Material Design Icons)
- No visible attribution is required on your map; keep the library's license notice if you redistribute the icon files
See the attribution requirements in the documentation for details.
FAQ
What is the Map Marker Icon API?
The Map Marker Icon API allows you to generate custom map marker icons as PNG images using URL parameters. You can choose styles, colors, icons, and sizes — making it easy to create branded and retina-ready markers for web maps. All parameters are described in the Marker Icon API documentation.
What formats does the API support?
The API outputs high-resolution PNG images, optimized for both standard and retina displays. These markers can be used directly in web mapping libraries like Leaflet, MapLibre GL, Google Maps, Mapbox GL JS, and OpenLayers.
Do I need to attribute Geoapify when using the API?
If you're using the Free plan, yes — attribution to Geoapify is required. A suggested attribution is: "Map marker icons are generated with Geoapify." Paid plans with white-label support do not require attribution.
Are there any usage limits?
The Free plan includes 3,000 credits per day, and each icon request costs 1 credit. If you generate icons and host them yourself, there are no usage limits from Geoapify. You can find more details on the pricing page.
Can I use the icons offline or host them myself?
Yes. You can generate PNG icons using the API and store them locally for use in offline maps or static content. There are no restrictions from Geoapify on redistributing the rendered PNGs.
Are there any licensing requirements for the icon libraries?
Yes for Font Awesome: Font Awesome Free icons are licensed under CC BY 4.0 (the fonts under the SIL Open Font License 1.1), so markers with Font Awesome icons or the Font Awesome pin shape (type=awesome) need attribution to Font Awesome. Material Icons and Material Symbols (Apache License 2.0), Lucide (ISC), Tabler Icons (MIT), Phosphor Icons (MIT) and Material Design Icons (Pictogrammers Free License) don't require visible attribution; keep the license notice if you redistribute icon files. See the attribution requirements.
How do I get sharp markers on retina screens?
Add scaleFactor=2 to the icon URL. The API returns the PNG at twice the pixel size, and you display it at the normal size (for example, a size=60 marker is 92 × 134 px, shown as 46 × 67 px). scaleFactor accepts values from 0.5 to 10.
How do I use a marker PNG as a custom Leaflet icon?
Pass the icon URL to L.icon() as iconUrl, set iconSize to [Icon-Width, Icon-Height] and iconAnchor to [Icon-Anchor-X, Icon-Anchor-Y] from the response headers, then use it in L.marker(). See the Leaflet example above or the Add Custom Marker Icons guide.
Which icon libraries can I use in map markers?
Set iconType to material, material-symbols, material-symbols-rounded, awesome (Font Awesome 6 Free), lucide, tabler, phosphor or mdi (Material Design Icons), and icon to an icon name from that library. Pin shapes and icon libraries can be mixed, for example type=awesome&iconType=mdi&icon=bicycle. See the API reference for the icon catalogs.
How do I find a marker's size and anchor point?
Read the Icon-Width, Icon-Height, Icon-Anchor-X and Icon-Anchor-Y response headers. They give the display size in CSS pixels, including the shadow, and the point that touches the map location. A HEAD request with the same parameters returns only the headers. See Shadows and map placement.