<!--
{
  "availability" : [
    "MapKit JS: 5.74.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/ImageDelegate",
  "metadataVersion" : "0.1.0",
  "role" : "Interface",
  "symbol" : {
    "kind" : "Interface",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "struct/mapkit.ImageDelegate"
  },
  "title" : "ImageDelegate"
}
-->

# ImageDelegate

An object you use to provide images for annotations.

```
interface ImageDelegate
```

## Overview

In addition to using a dictionary object that defines image URLs for [`ImageAnnotation`](/documentation/MapKitJS/ImageAnnotation) or [`MarkerAnnotation`](/documentation/MapKitJS/MarkerAnnotation), you can specify an image delegate that allows you to return an image dynamically or asynchronously.

Implement [`getImage(ratio)`](/documentation/MapKitJS/ImageDelegate/getImage) to return a `Promise` that resolves to a URL string, an [`ImageSource`](/documentation/MapKitJS/ImageSource), or `undefined`:

```javascript
const imageDelegate = {
    async getImage(scale) {
        const response = await fetch(`https://example.com/images/marker?scale=${scale}`, {
            headers: { "Authorization": "Bearer " + token }
        });
        if (!response.ok) return undefined;
        const blob = await response.blob();
        return createImageBitmap(blob);
    }
};

const annotation = new mapkit.MarkerAnnotation(
    new mapkit.Coordinate(10, 10),
    {
        glyphImage: imageDelegate
    }
);
```

## Topics

### Returning an image

[`getImage(ratio)`](/documentation/MapKitJS/ImageDelegate/getImage)

Returns an image for the specified scale.

[`getImageUrl(ratio, callback)`](/documentation/MapKitJS/ImageDelegate/getImageUrl)

Returns the URL to an image of the specified scale.

## Relationships

### Conforming Types

[`MapFeatureAnnotationGlyphImage`](/documentation/MapKitJS/MapFeatureAnnotationGlyphImage)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)