<!--
{
  "availability" : [
    "MapKit JS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "MapKitJS",
  "identifier" : "/documentation/MapKitJS/ImageDelegate/getImage",
  "metadataVersion" : "0.1.0",
  "role" : "Interface Method",
  "symbol" : {
    "kind" : "Interface Method",
    "modules" : [
      "MapKit JS"
    ],
    "preciseIdentifier" : "structm/mapkit.ImageDelegate/getImage"
  },
  "title" : "getImage(ratio)"
}
-->

# getImage(ratio)

Returns an image for the specified scale.

```
getImage?(ratio: number): Promise<string | ImageSource | undefined>;
```

## Discussion

Implement this method to return a `Promise` that resolves to a URL string, an [`ImageSource`](/documentation/MapKitJS/ImageSource), or `undefined` if no image is available. MapKit JS calls this method with a pixel ratio value that your function uses to provide an appropriately scaled image.

When both [`getImage(ratio)`](/documentation/MapKitJS/ImageDelegate/getImage) and [`getImageUrl(ratio, callback)`](/documentation/MapKitJS/ImageDelegate/getImageUrl) are present, the framework uses [`getImage(ratio)`](/documentation/MapKitJS/ImageDelegate/getImage).

```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.ImageAnnotation(
    new mapkit.Coordinate(10, 10),
    { image: imageDelegate }
);
```

---

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)