ym.modules.provider.TileLayer

Overview

Used to load and display tile layers on the map. Implements the ILayer interface.

Example call

 L.tileLayer('http://{s}.tile.osm.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar'}).addTo(map);   

Initialization

Factory: ym.tileLayer(urlTemplate, options)

Instantiates a tile layer object with a URL template and optionally an options object.

Parameter

Name Description Data type Default value
bounds [required] string  
options [optional] TileLayerOptions  

Parameter: urlTemplate

A string of the following form:

http://{s}.somedomain.com/anything/{z}/{x}/{y}.png  

{s} means one of the available subdomains (used sequentially to help with browser parallel requests per domain boundary; subdomain values are specified in options; {z} - zoom level, {x} and {y} - tile coordinates.

You can use custom keys in the template, which are evaluated using the TileLayer options:

 L.tileLayer('http://{s}.somedomain.com/{foo}/{z}/{x}/{y}.png', {foo: 'bar'});   

Parameter: options

Name Description Data type Default value
attribution For example "© Mapbox" - the string used by the attribution control describes the layer data. string ''
bounds If this option is set, TileLayer only loads tiles that are located within the specified geographic boundaries. LatLngBounds null
continuousWorld If set to true the tile coordinates are not wrapped around the world latitude (-180 to 180 degrees of longitude) or clamped so that they are within the world altitude (-90 to 90). Use this option if you use the leaflet for cards that do not reflect the real world (for example playing cards, interior cards, or photo cards). bool false
detectRetina If true and the user is on a retina display, it requests four tiles of half size and a higher zoom level to take advantage of the high resolution. bool false
errorTileUrl URL to the tile image that is displayed instead of the tile that could not be loaded. string ''
maxNativeZoom Maximum zoom number provided by the tile source. If specified, tiles at all zoom levels higher than maxNativeZoom are loaded from the maxNativeZoom level and automatically scaled. int null
maxZoom Maximum zoom number. int 18
minZoom Minimum zoom number. int 0
noWrap If set to true, the tiles are only loaded outside the world latitude (-180 to 180 degrees longitude) instead of repeating themselves. bool false
opacity The opacity of the tile layer. int 1.0
reuseTiles If true, all tiles that are not visible after panning are put into a reuse queue from which they are fetched when new tiles become visible (as opposed to dynamically creating new ones). This will keep memory consumption low and eliminate the need to reserve memory for new tiles. bool false
subdomains Subdomains of the tile service. Can be passed in the form of a string (where each character is a subdomain name) or an array of strings. string oder string[] 'abc'
tileSize Tile size (width and height in pixels, provided the tiles are square). int 256
tms If true, the Y-axis numbering is reversed for tiles (switch on for TMS services). bool false
unloadInvisibleTiles If true, all tiles that are not visible after panning are removed (for better performance). Is true by default on mobile WebKit, otherwise false. bool  
updateWhenIdle If false, new tiles are loaded during panning, otherwise only after that (for better performance). Is true by default on mobile WebKit, otherwise false. bool  
zIndex The explicit zIndex of the tile layer. Not set by default. int null
zoomOffset This value is added to the zoom number used in tile URLs. int 0
zoomReverse If set to true true the zoom number used in the tile URLs is reversed (maxZoom - zoom instead of zoom). bool false

Ereignisse from v3

Event Event type Description
loading Event Is triggered when the tile layer starts loading the tiles.
load Event Is triggered after the tile layer has loaded all visible tiles.
tileloadstart TileEvent Is triggered when a tile is requested and starts loading.
tileload TileEvent Is triggered when a tile is loaded.
tileunload TileEvent Is triggered when a tile is removed (for example, if you have enabled unloadInvisibleTiles).
tileerror TileEvent Is triggered when an error occurs while loading a tile.

Methoden

addTo(map) from v3

Adds the layer to the map.

Parameter

Name Description Data type Default value
map   Map  

Return

this

bringToFront() from v3

Brings the tile layer to the top of all tile layers.

Return

this

bringToBack() from v3

Brings the tile layer to the bottom of all tile layers.

Return

this

setOpacity(opacity) from v3

Changes the opacity of the tile layer.

Parameter

Name Description Data type Default value
opacity   int  

Return

this

setZIndex(zIndex) from v3

Sets the zIndex of the tile layer.

Parameter

Name Description Data type Default value
zIndex   int  

Return

this

redraw() from v3

Causes the layer to clear all the tiles and request them again.

Return

this

setUrl(urlTemplate) from v3

Updates the layer’s URL template and redraws it.

Parameter

Name Description Data type Default value
urlTemplate   string  

Return

this

getContainer() from v3

Returns the HTML element that contains the tiles for this layer.

Return

HTMLElement