---
title: getImage(ratio)
framework: mapkitjs
role: symbol
role_heading: Interface Method
path: mapkitjs/imagedelegate/getimage
---

# getImage(ratio)

Returns an image for the specified scale.

## Declaration

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

## Mentioned in

MapKit JS 6 Migrating from Version 5 to Version 6

## Discussion

Discussion Implement this method to return a Promise that resolves to a URL string, an 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) and getImageUrl(ratio, callback) are present, the framework uses getImage(ratio). 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 } );

## See Also

### Returning an image

- [getImageUrl(ratio, callback)](mapkitjs/imagedelegate/getimageurl.md)
