ImageViewer

MapTiler's ImageViewer component allows you to display tiled, non-georeferenced images but interact with them in almost the same way you would if you were displaying map. These can be handy for zoomable non-georeferenced, geographically "inaccurate" maps such as hotel maps, golf courses, theme parks etc. Think pixels instead of lattitudes and longtidues.

You create a ImageViewer by specifying a container and other options. Then SDK JS initializes the viewer on the page and returns your ImageViewer object.

Extends Evented.

Example

Parameters

Options to provide to the ImageViewer constructor (ImageViewerConstructorOptions)

Properties

options.apiKey MapTiler logo Define the MapTiler API key to be used. This is equivalent to setting config.apiKey and will overwrite it.
options.container The HTML element in which SDK JS will render the viewer, or the element's string id.
options.imageUUID MapTiler logo The unique UUID of the image object you are displaying.
options.center
[number, number]?
default: the center of the image
The initial centerpoint in pixels of the viewer.
options.zoom
default: 0
The initial zoom level of the viewer.
options.bearing
default: 0
The initial bearing (rotation) of the viewer, measured in degrees counter-clockwise from north.
options.debug
default: false
Whether to show tiles debug information.
options.fitToBoundsControl
default: true
Whether to show a control to fit the image to the viewport.
options.navigationControl
default: true
Whether to show a navigation control.
options.maxZoom The maximum zoom level of the viewer.
options.minZoom The minimum zoom level of the viewer.

Methods

ImageViewer provides a subset of methods for interaction with the map. A major caveat is that the ImageViewer component works in pixels and not in LngLat. Thus, when using methods such as setCenter or flyTo the pixel values provided refer to the absolute pixel position on the image, not screen pixel position.

Imagine your image is 10,000px x 10,000px, if regardless if your zoom is 2 or 4, calling .setCenter(500,500) will always position the viewer over the same part of the image.

Events

In a similar manner, a subset of map events are fired by the image viewer. All UI interaction events that would normally include a LngLat in the event data instead receive an imageX and imageY field, representing an absolute pixel position of the image. This is same for flyTo, jumpTo, panTo etc.

A full list of supported events can be found in the exported type declaration ImageViewerEventTypes

Reference documentation of MapTiler SDK JS, an extension of MapLibre GL JS