Skip to content

Use a fallback image

Use a coalesce expression to display another image when a requested image is not available.

---
title: Use a fallback image
description: Use a coalesce expression to display another image when a requested image is not available.
options:
  center: [-77, 38.75]
  zoom: 5
style:
  layers:
    - type: symbol
      icon-image:
        - coalesce
        - [image, [concat, "maki:", [get, icon]]]
        - [image, maki:marker]
  extends: https://styles.trailsta.sh/osm-liberty.json
---
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -77.03238901390978,
          38.913188059745586
        ]
      },
      "properties": {
        "title": "Washington DC",
        "icon": "monument"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -79.9959,
          40.4406
        ]
      },
      "properties": {
        "title": "Pittsburgh",
        "icon": "bridges"
      }
    },
    {
      "type": "Feature",
      "geometry": {
        "type": "Point",
        "coordinates": [
          -76.2859,
          36.8508
        ]
      },
      "properties": {
        "title": "Norfolk",
        "icon": "harbor"
      }
    }
  ]
}


View Map on Ultra
Edit Query on Ultra
View MapLibre Example