TileLayer.js (Leaflet-1.8.0) | : | TileLayer.js (Leaflet-1.9.0) | ||
---|---|---|---|---|
skipping to change at line 16 | skipping to change at line 16 | |||
/* | /* | |||
* @class TileLayer | * @class TileLayer | |||
* @inherits GridLayer | * @inherits GridLayer | |||
* @aka L.TileLayer | * @aka L.TileLayer | |||
* Used to load and display tile layers on the map. Note that most tile servers require attribution, which you can set under `Layer`. Extends `GridLayer`. | * Used to load and display tile layers on the map. Note that most tile servers require attribution, which you can set under `Layer`. Extends `GridLayer`. | |||
* | * | |||
* @example | * @example | |||
* | * | |||
* ```js | * ```js | |||
* L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'bar', attribution: '© <a href="https://www.openstreetmap.org/copyright">O penStreetMap</a> contributors'}).addTo(map); | * L.tileLayer('https://tile.openstreetmap.org/{z}/{x}/{y}.png?{foo}', {foo: 'ba r', attribution: '© <a href="https://www.openstreetmap.org/copyright">OpenS treetMap</a> contributors'}).addTo(map); | |||
* ``` | * ``` | |||
* | * | |||
* @section URL template | * @section URL template | |||
* @example | * @example | |||
* | * | |||
* A string of the following form: | * A string of the following form: | |||
* | * | |||
* ``` | * ``` | |||
* 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png' | * 'https://{s}.somedomain.com/blabla/{z}/{x}/{y}{r}.png' | |||
* ``` | * ``` | |||
skipping to change at line 102 | skipping to change at line 102 | |||
options = Util.setOptions(this, options); | options = Util.setOptions(this, options); | |||
// detecting retina displays, adjusting tileSize and zoom levels | // detecting retina displays, adjusting tileSize and zoom levels | |||
if (options.detectRetina && Browser.retina && options.maxZoom > 0 ) { | if (options.detectRetina && Browser.retina && options.maxZoom > 0 ) { | |||
options.tileSize = Math.floor(options.tileSize / 2); | options.tileSize = Math.floor(options.tileSize / 2); | |||
if (!options.zoomReverse) { | if (!options.zoomReverse) { | |||
options.zoomOffset++; | options.zoomOffset++; | |||
options.maxZoom--; | options.maxZoom = Math.max(options.minZoom, optio ns.maxZoom - 1); | |||
} else { | } else { | |||
options.zoomOffset--; | options.zoomOffset--; | |||
options.minZoom++; | options.minZoom = Math.min(options.maxZoom, optio ns.minZoom + 1); | |||
} | } | |||
options.minZoom = Math.max(0, options.minZoom); | options.minZoom = Math.max(0, options.minZoom); | |||
} else if (!options.zoomReverse) { | ||||
// make sure maxZoom is gte minZoom | ||||
options.maxZoom = Math.max(options.minZoom, options.maxZo | ||||
om); | ||||
} else { | ||||
// make sure minZoom is lte maxZoom | ||||
options.minZoom = Math.min(options.maxZoom, options.minZo | ||||
om); | ||||
} | } | |||
if (typeof options.subdomains === 'string') { | if (typeof options.subdomains === 'string') { | |||
options.subdomains = options.subdomains.split(''); | options.subdomains = options.subdomains.split(''); | |||
} | } | |||
this.on('tileunload', this._onTileRemove); | this.on('tileunload', this._onTileRemove); | |||
}, | }, | |||
// @method setUrl(url: String, noRedraw?: Boolean): this | // @method setUrl(url: String, noRedraw?: Boolean): this | |||
skipping to change at line 155 | skipping to change at line 161 | |||
if (this.options.crossOrigin || this.options.crossOrigin === '') { | if (this.options.crossOrigin || this.options.crossOrigin === '') { | |||
tile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin; | tile.crossOrigin = this.options.crossOrigin === true ? '' : this.options.crossOrigin; | |||
} | } | |||
// for this new option we follow the documented behavior | // for this new option we follow the documented behavior | |||
// more closely by only setting the property when string | // more closely by only setting the property when string | |||
if (typeof this.options.referrerPolicy === 'string') { | if (typeof this.options.referrerPolicy === 'string') { | |||
tile.referrerPolicy = this.options.referrerPolicy; | tile.referrerPolicy = this.options.referrerPolicy; | |||
} | } | |||
/* | // The alt attribute is set to the empty string, | |||
Alt tag is set to empty string to keep screen readers from readi | // allowing screen readers to ignore the decorative image tiles. | |||
ng URL and for compliance reasons | // https://www.w3.org/WAI/tutorials/images/decorative/ | |||
https://www.w3.org/TR/WCAG20-TECHS/H67 | // https://www.w3.org/TR/html-aria/#el-img-empty-alt | |||
*/ | ||||
tile.alt = ''; | tile.alt = ''; | |||
/* | ||||
Set role="presentation" to force screen readers to ignore this | ||||
https://www.w3.org/TR/wai-aria/roles#textalternativecomputation | ||||
*/ | ||||
tile.setAttribute('role', 'presentation'); | ||||
tile.src = this.getTileUrl(coords); | tile.src = this.getTileUrl(coords); | |||
return tile; | return tile; | |||
}, | }, | |||
// @section Extension methods | // @section Extension methods | |||
// @uninheritable | // @uninheritable | |||
// Layers extending `TileLayer` might reimplement the following method. | // Layers extending `TileLayer` might reimplement the following method. | |||
// @method getTileUrl(coords: Object): String | // @method getTileUrl(coords: Object): String | |||
// Called only internally, returns the URL for a tile given its coordinat es. | // Called only internally, returns the URL for a tile given its coordinat es. | |||
End of changes. 6 change blocks. | ||||
14 lines changed or deleted | 15 lines changed or added |