---
title: "ImageSource | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Class ImageSource`Maptiler`

A data source containing an image. (See the [Style Specification](https://maplibre.org/maplibre-style-spec/#sources-image) for detailed documentation of options.)

#### Example[](#example)

```typescript
// add to map
map.addSource('some id', {
   type: 'image',
   url: 'https://www.maplibre.org/images/foo.png',
   coordinates: [
       [-76.54, 39.18],
       [-76.52, 39.18],
       [-76.52, 39.17],
       [-76.54, 39.17]
   ]
});

// update coordinates
let mySource = map.getSource('some id');
mySource.setCoordinates([
    [-76.54335737228394, 39.18579907229748],
    [-76.52803659439087, 39.1838364847587],
    [-76.5295386314392, 39.17683392507606],
    [-76.54520273208618, 39.17876344106642]
]);

// update url and coordinates simultaneously
mySource.updateImage({
   url: 'https://www.maplibre.org/images/bar.png',
   coordinates: [
       [-76.54335737228394, 39.18579907229748],
       [-76.52803659439087, 39.1838364847587],
       [-76.5295386314392, 39.17683392507606],
       [-76.54520273208618, 39.17876344106642]
   ]
})

map.removeSource('some id');  // remove
```

#### Hierarchy ([View Summary](https://docs.maptiler.com/sdk-js/api-reference/hierarchy/#ImageSource))

-   [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/)
    -   ImageSource

##### Index

### Constructors[](#constructors)

[constructor](#constructor)

### Properties[](#properties)

[coordinates](#coordinates) [dispatcher](#dispatcher) [flippedWindingOrder](#flippedwindingorder) [id](#id) [image](#image) [map](#map) [maxzoom](#maxzoom) [minzoom](#minzoom) [options](#options) [terrainTileRanges](#terraintileranges) [texture](#texture) [tileCoords](#tilecoords) [tileID](#tileid) [tiles](#tiles) [tileSize](#tilesize) [type](#type) [url](#url)

### Methods[](#methods)

[fire](#fire) [hasTransition](#hastransition) [listens](#listens) [load](#load) [loaded](#loaded) [loadTile](#loadtile) [off](#off) [on](#on) [onAdd](#onadd) [once](#once) [onRemove](#onremove) [prepare](#prepare) [serialize](#serialize) [setCoordinates](#setcoordinates) [setEventedParent](#seteventedparent) [updateImage](#updateimage)

## Constructors[](#constructors-1)

### constructor[](#constructor)

-   new ImageSource(  
        id: string,  
        options:  
            | [CanvasSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/CanvasSourceSpecification/)  
            | [VideoSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/VideoSourceSpecification/)  
            | [ImageSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/ImageSourceSpecification/),  
        dispatcher: [Dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Dispatcher/),  
        eventedParent: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/),  
    ): ImageSource[](#constructorimagesource)
    
    #### Parameters
    
    -   id: string
    -   options: [CanvasSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/CanvasSourceSpecification/) | [VideoSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/VideoSourceSpecification/) | [ImageSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/ImageSourceSpecification/)
    -   dispatcher: [Dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Dispatcher/)
    -   eventedParent: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/)
    
    #### Returns ImageSource
    
    #### Internal[](#internal)
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[constructor](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#constructor)
    

## Properties[](#properties-1)

### coordinates[](#coordinates)

coordinates: [Coordinates](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Coordinates/)

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[coordinates](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#coordinates)

### dispatcher[](#dispatcher)

dispatcher: [Dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Dispatcher/)

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[dispatcher](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#dispatcher)

### flippedWindingOrder[](#flippedwindingorder)

flippedWindingOrder: boolean

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[flippedWindingOrder](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#flippedwindingorder)

### id[](#id)

id: string

The id for the source. Must not be used by any existing source.

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[id](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#id)

### image[](#image)

image: [ImageBitmap](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.ImageBitmap/) | [HTMLImageElement](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Externals.HTMLImageElement/)

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[image](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#image)

### map[](#map)

map: [MapLibreMap](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreMap/)

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[map](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#map)

### maxzoom[](#maxzoom)

maxzoom: number

The maximum zoom level for the source.

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[maxzoom](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#maxzoom)

### minzoom[](#minzoom)

minzoom: number

The minimum zoom level for the source.

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[minzoom](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#minzoom)

### options[](#options)

options: any

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[options](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#options)

### terrainTileRanges[](#terraintileranges)

terrainTileRanges: { \[zoom: string\]: [CanonicalTileRange](https://docs.maptiler.com/sdk-js/api-reference/types/CanonicalTileRange/) }

This object is used to store the range of terrain tiles that overlap with this tile. It is relevant for image tiles, as the image exceeds single tile boundaries.

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[terrainTileRanges](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#terraintileranges)

### texture[](#texture)

texture: [Texture](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Texture/) | null

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[texture](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#texture)

### tileCoords[](#tilecoords)

tileCoords: [Point](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Point/)\[\]

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[tileCoords](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#tilecoords)

### tileID[](#tileid)

tileID: [CanonicalTileID](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.CanonicalTileID/)

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[tileID](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#tileid)

### tiles[](#tiles)

tiles: { \[\_: string\]: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/) }

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[tiles](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#tiles)

### tileSize[](#tilesize)

tileSize: number

The tile size for the source.

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[tileSize](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#tilesize)

### type[](#type)

type: string

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[type](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#type)

### url[](#url)

url: string

Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[url](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#url)

## Methods[](#methods-1)

### fire[](#fire)

-   fire(event: string | [Event](https://docs.maptiler.com/sdk-js/api-reference/classes/Event/), properties?: any): this[](#fire-1)
    
    An ability to fire an event to all the listeners, see [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/)
    
    #### Parameters
    
    -   event: string | [Event](https://docs.maptiler.com/sdk-js/api-reference/classes/Event/)
        
        The event to fire
        
    -   `Optional`properties: any
    
    #### Returns this
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[fire](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#fire)
    

### hasTransition[](#hastransition)

-   hasTransition(): boolean[](#hastransition-1)
    
    True if the source has transition, false otherwise.
    
    #### Returns boolean
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[hasTransition](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#hastransition)
    

### listens[](#listens)

-   listens(type: string): boolean[](#listens-1)
    
    Returns a true if this instance of Evented or any forwardeed instances of Evented have a listener for the specified type.
    
    #### Parameters
    
    -   type: string
        
        The event type
        
    
    #### Returns boolean
    
    `true` if there is at least one registered listener for specified event type, `false` otherwise
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[listens](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#listens)
    

### load[](#load)

-   load(newCoordinates?: [Coordinates](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Coordinates/)): Promise<void\>[](#load-1)
    
    #### Parameters
    
    -   `Optional`newCoordinates: [Coordinates](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Coordinates/)
    
    #### Returns Promise<void\>
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[load](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#load)
    

### loaded[](#loaded)

-   loaded(): boolean[](#loaded-1)
    
    True if the source is loaded, false otherwise.
    
    #### Returns boolean
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[loaded](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#loaded)
    

### loadTile[](#loadtile)

-   loadTile(tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)): Promise<void\>[](#loadtile-1)
    
    This method does the heavy lifting of loading a tile. In most cases it will defer the work to the relevant worker source.
    
    #### Parameters
    
    -   tile: [Tile](https://docs.maptiler.com/sdk-js/api-reference/classes/Tile/)
        
        The tile to load
        
    
    #### Returns Promise<void\>
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[loadTile](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#loadtile)
    

### off[](#off)

-   off(type: string, listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)): this[](#off-1)
    
    Removes a previously registered event listener.
    
    #### Parameters
    
    -   type: string
        
        The event type to remove listeners for.
        
    -   listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)
        
        The listener function to remove.
        
    
    #### Returns this
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[off](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#off)
    

### on[](#on)

-   on(type: string, listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)): [Subscription](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Subscription/)[](#on-1)
    
    Adds a listener to a specified event type.
    
    #### Parameters
    
    -   type: string
        
        The event type to add a listen for.
        
    -   listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)
        
        The function to be called when the event is fired. The listener function is called with the data object passed to `fire`, extended with `target` and `type` properties.
        
    
    #### Returns [Subscription](https://docs.maptiler.com/sdk-js/api-reference/interfaces/Subscription/)
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[on](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#on)
    

### `Maptiler`onAdd[](#onadd)

-   onAdd(map: [MapLibreMap](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreMap/) | [Map](https://docs.maptiler.com/sdk-js/api-reference/classes/Map/)): void[](#onadd-1)
    
    This method is called when the source is added to the map.
    
    #### Parameters
    
    -   map: [MapLibreMap](https://docs.maptiler.com/sdk-js/api-reference/classes/MapLibreMap/) | [Map](https://docs.maptiler.com/sdk-js/api-reference/classes/Map/)
        
        The map instance
        
    
    #### Returns void
    
    Overrides [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[onAdd](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#onadd)
    

### once[](#once)

-   once(type: string, listener?: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)): Promise<any\> | ImageSource[](#once-1)
    
    Adds a listener that will be called only once to a specified event type.
    
    The listener will be called first time the event fires after the listener is registered.
    
    #### Parameters
    
    -   type: string
        
        The event type to listen for.
        
    -   `Optional`listener: [Listener](https://docs.maptiler.com/sdk-js/api-reference/types/Listener/)
        
        The function to be called when the event is fired the first time.
        
    
    #### Returns Promise<any\> | ImageSource
    
    `this` or a promise if a listener is not provided
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[once](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#once)
    

### onRemove[](#onremove)

-   onRemove(): void[](#onremove-1)
    
    This method is called when the source is removed from the map.
    
    #### Returns void
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[onRemove](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#onremove)
    

### prepare[](#prepare)

-   prepare(): void[](#prepare-1)
    
    Allows to execute a prepare step before the source is used.
    
    #### Returns void
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[prepare](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#prepare)
    

### serialize[](#serialize)

-   serialize(): | [CanvasSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/CanvasSourceSpecification/)  
    | [VideoSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/VideoSourceSpecification/)  
    | [ImageSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/ImageSourceSpecification/)[](#serialize-1)
    
    #### Returns [CanvasSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/CanvasSourceSpecification/) | [VideoSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/VideoSourceSpecification/) | [ImageSourceSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/ImageSourceSpecification/)
    
    A plain (stringifiable) JS object representing the current state of the source. Creating a source using the returned object as the `options` should result in a Source that is equivalent to this one.
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[serialize](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#serialize)
    

### setCoordinates[](#setcoordinates)

-   setCoordinates(coordinates: [Coordinates](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Coordinates/)): this[](#setcoordinates-1)
    
    Sets the image's coordinates and re-renders the map.
    
    #### Parameters
    
    -   coordinates: [Coordinates](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.Coordinates/)
        
        Four geographical coordinates, represented as arrays of longitude and latitude numbers, which define the corners of the image. The coordinates start at the top left corner of the image and proceed in clockwise order. They do not have to represent a rectangle.
        
    
    #### Returns this
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[setCoordinates](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#setcoordinates)
    

### setEventedParent[](#seteventedparent)

-   setEventedParent(parent?: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/) | null, data?: any): this[](#seteventedparent-1)
    
    Bubble all events fired by this instance of Evented to this parent instance of Evented.
    
    #### Parameters
    
    -   `Optional`parent: [Evented](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.Evented/) | null
    -   `Optional`data: any
    
    #### Returns this
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[setEventedParent](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#seteventedparent)
    

### updateImage[](#updateimage)

-   updateImage(options: [UpdateImageOptions](https://docs.maptiler.com/sdk-js/api-reference/types/UpdateImageOptions/)): this[](#updateimage-1)
    
    Updates the image URL and, optionally, the coordinates. To avoid having the image flash after changing, set the `raster-fade-duration` paint property on the raster layer to 0.
    
    #### Parameters
    
    -   options: [UpdateImageOptions](https://docs.maptiler.com/sdk-js/api-reference/types/UpdateImageOptions/)
        
        The options object.
        
    
    #### Returns this
    
    Inherited from [ImageSource](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/).[updateImage](https://docs.maptiler.com/sdk-js/api-reference/classes/Externals.ImageSource/#updateimage)
