diff --git a/examples/tileutfgrid.js b/examples/tileutfgrid.js index 5f0fca89a8..cfaf33e972 100644 --- a/examples/tileutfgrid.js +++ b/examples/tileutfgrid.js @@ -30,7 +30,7 @@ var map = new ol.Map({ }); var flag = document.getElementById('flag'); -var admin_name = document.getElementById('admin_name'); +var adminName = document.getElementById('admin_name'); map.on('pointermove', function(evt) { var viewResolution = /** @type {number} */ (view.getResolution()); gridSource.forDataAtCoordinateAndResolution(evt.coordinate, viewResolution, @@ -42,7 +42,7 @@ map.on('pointermove', function(evt) { /* jshint -W069 */ flag.src = data ? 'data:image/png;base64,' + data['flag_png'] : ''; flag.style.visibility = data ? 'visible' : 'hidden'; - admin_name.innerHTML = data ? data['admin'] : ' '; + adminName.innerHTML = data ? data['admin'] : ' '; /* jshint +W069 */ }); }); diff --git a/src/ol/source/tileutfgridsource.js b/src/ol/source/tileutfgridsource.js index 16d3caa068..7043902816 100644 --- a/src/ol/source/tileutfgridsource.js +++ b/src/ol/source/tileutfgridsource.js @@ -91,20 +91,20 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() { /** * @param {ol.Coordinate} coordinate Coordinate. * @param {number} resolution Resolution. - * @param {function(this: T, (Object|undefined))} f Callback. - * @param {T=} opt_this The object to use as `this` in `f`. + * @param {function(this: T, (Object|undefined))} callback Callback. + * @param {T=} opt_this The object to use as `this` in the callback. * @param {boolean=} opt_noRequest Only process already loaded data. * @template T * @api */ ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function( - coordinate, resolution, f, opt_this, opt_noRequest) { + coordinate, resolution, callback, opt_this, opt_noRequest) { if (!goog.isNull(this.tileGrid)) { var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution( coordinate, resolution); var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile( tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection())); - tile.forDataAtCoordinate(coordinate, f, opt_this, opt_noRequest); + tile.forDataAtCoordinate(coordinate, callback, opt_this, opt_noRequest); } }; @@ -247,19 +247,19 @@ ol.source.TileUTFGridTile_ = /** * @private - * @type {?Array.} + * @type {Array.} */ this.grid_ = null; /** * @private - * @type {?Array.} + * @type {Array.} */ this.keys_ = null; /** * @private - * @type {?Object.|undefined} + * @type {Object.|undefined} */ this.data_ = null; }; @@ -285,9 +285,9 @@ ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) { return undefined; } var xRelative = (coordinate[0] - this.extent_[0]) / - (this.extent_[2] - this.extent_[0]); + (this.extent_[2] - this.extent_[0]); var yRelative = (coordinate[1] - this.extent_[1]) / - (this.extent_[3] - this.extent_[1]); + (this.extent_[3] - this.extent_[1]); var row = this.grid_[Math.floor((1 - yRelative) * this.grid_.length)]; @@ -296,8 +296,12 @@ ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) { } var code = row.charCodeAt(Math.floor(xRelative * row.length)); - if (code >= 93) code--; - if (code >= 35) code--; + if (code >= 93) { + code--; + } + if (code >= 35) { + code--; + } code -= 32; var key = this.keys_[code]; @@ -307,23 +311,23 @@ ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) { /** - * Calls `f` when the data for given coordinate is available. + * Calls the callback when the data for given coordinate is available. * @param {ol.Coordinate} coordinate Coordinate. - * @param {function(this: T, (Object|undefined))} f Callback. - * @param {T=} opt_this The object to use as `this` in `f`. + * @param {function(this: T, (Object|undefined))} callback Callback. + * @param {T=} opt_this The object to use as `this` in the callback. * @param {boolean=} opt_noRequest If not loaded, callback with `undefined` * without loading the tile. * @template T */ ol.source.TileUTFGridTile_.prototype.forDataAtCoordinate = - function(coordinate, f, opt_this, opt_noRequest) { + function(coordinate, callback, opt_this, opt_noRequest) { if (this.state == ol.TileState.IDLE && opt_noRequest !== true) { - this.listenOnce(goog.events.EventType.CHANGE, function(e) { - f.call(opt_this, this.getData(coordinate)); + goog.events.listenOnce(this, goog.events.EventType.CHANGE, function(e) { + callback.call(opt_this, this.getData(coordinate)); }, false, this); this.loadInternal_(); } else { - f.call(opt_this, this.getData(coordinate)); + callback.call(opt_this, this.getData(coordinate)); } };