Maps SDK for Web

tt.ImageSource

An image source. The "url" value contains the image location. The "coordinates" array contains [longitude, latitude] pairs for the image corners listed in clockwise order: top left, top right, bottom right, bottom left.

Properties

coordintates: Array

Array of corners of image specified as longitude, latitude pairs.

url: String

URL that points to an image.

Methods

setCoordinates(coordinates): tt.ImageSource

Sets the image's coordinates and re-renders the map.

Example
const imageSource = map.getSource('my-image'):

imageSource.setCoordinates([
    [21.54, 52.18],
    [21.52, 52.18],
    [21.52, 52.17],
    [21.54, 52.17]
]);
Parameters
Name Description
coordinates
Array
default:None
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

updateImage(url, coordinates): tt.ImageSource

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
Name Description
url
String
default:None
Required image URL.
coordinates
Array
default:None
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