Various code style fixes
This commit is contained in:
@@ -30,7 +30,7 @@ var map = new ol.Map({
|
|||||||
});
|
});
|
||||||
|
|
||||||
var flag = document.getElementById('flag');
|
var flag = document.getElementById('flag');
|
||||||
var admin_name = document.getElementById('admin_name');
|
var adminName = document.getElementById('admin_name');
|
||||||
map.on('pointermove', function(evt) {
|
map.on('pointermove', function(evt) {
|
||||||
var viewResolution = /** @type {number} */ (view.getResolution());
|
var viewResolution = /** @type {number} */ (view.getResolution());
|
||||||
gridSource.forDataAtCoordinateAndResolution(evt.coordinate, viewResolution,
|
gridSource.forDataAtCoordinateAndResolution(evt.coordinate, viewResolution,
|
||||||
@@ -42,7 +42,7 @@ map.on('pointermove', function(evt) {
|
|||||||
/* jshint -W069 */
|
/* jshint -W069 */
|
||||||
flag.src = data ? 'data:image/png;base64,' + data['flag_png'] : '';
|
flag.src = data ? 'data:image/png;base64,' + data['flag_png'] : '';
|
||||||
flag.style.visibility = data ? 'visible' : 'hidden';
|
flag.style.visibility = data ? 'visible' : 'hidden';
|
||||||
admin_name.innerHTML = data ? data['admin'] : ' ';
|
adminName.innerHTML = data ? data['admin'] : ' ';
|
||||||
/* jshint +W069 */
|
/* jshint +W069 */
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -91,20 +91,20 @@ ol.source.TileUTFGrid.prototype.getTemplate = function() {
|
|||||||
/**
|
/**
|
||||||
* @param {ol.Coordinate} coordinate Coordinate.
|
* @param {ol.Coordinate} coordinate Coordinate.
|
||||||
* @param {number} resolution Resolution.
|
* @param {number} resolution Resolution.
|
||||||
* @param {function(this: T, (Object|undefined))} f Callback.
|
* @param {function(this: T, (Object|undefined))} callback Callback.
|
||||||
* @param {T=} opt_this The object to use as `this` in `f`.
|
* @param {T=} opt_this The object to use as `this` in the callback.
|
||||||
* @param {boolean=} opt_noRequest Only process already loaded data.
|
* @param {boolean=} opt_noRequest Only process already loaded data.
|
||||||
* @template T
|
* @template T
|
||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
ol.source.TileUTFGrid.prototype.forDataAtCoordinateAndResolution = function(
|
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)) {
|
if (!goog.isNull(this.tileGrid)) {
|
||||||
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
|
var tileCoord = this.tileGrid.getTileCoordForCoordAndResolution(
|
||||||
coordinate, resolution);
|
coordinate, resolution);
|
||||||
var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile(
|
var tile = /** @type {!ol.source.TileUTFGridTile_} */(this.getTile(
|
||||||
tileCoord[0], tileCoord[1], tileCoord[2], 1, this.getProjection()));
|
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
|
* @private
|
||||||
* @type {?Array.<string>}
|
* @type {Array.<string>}
|
||||||
*/
|
*/
|
||||||
this.grid_ = null;
|
this.grid_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {?Array.<string>}
|
* @type {Array.<string>}
|
||||||
*/
|
*/
|
||||||
this.keys_ = null;
|
this.keys_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {?Object.<string, Object>|undefined}
|
* @type {Object.<string, Object>|undefined}
|
||||||
*/
|
*/
|
||||||
this.data_ = null;
|
this.data_ = null;
|
||||||
};
|
};
|
||||||
@@ -285,9 +285,9 @@ ol.source.TileUTFGridTile_.prototype.getData = function(coordinate) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
var xRelative = (coordinate[0] - this.extent_[0]) /
|
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]) /
|
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)];
|
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));
|
var code = row.charCodeAt(Math.floor(xRelative * row.length));
|
||||||
if (code >= 93) code--;
|
if (code >= 93) {
|
||||||
if (code >= 35) code--;
|
code--;
|
||||||
|
}
|
||||||
|
if (code >= 35) {
|
||||||
|
code--;
|
||||||
|
}
|
||||||
code -= 32;
|
code -= 32;
|
||||||
|
|
||||||
var key = this.keys_[code];
|
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 {ol.Coordinate} coordinate Coordinate.
|
||||||
* @param {function(this: T, (Object|undefined))} f Callback.
|
* @param {function(this: T, (Object|undefined))} callback Callback.
|
||||||
* @param {T=} opt_this The object to use as `this` in `f`.
|
* @param {T=} opt_this The object to use as `this` in the callback.
|
||||||
* @param {boolean=} opt_noRequest If not loaded, callback with `undefined`
|
* @param {boolean=} opt_noRequest If not loaded, callback with `undefined`
|
||||||
* without loading the tile.
|
* without loading the tile.
|
||||||
* @template T
|
* @template T
|
||||||
*/
|
*/
|
||||||
ol.source.TileUTFGridTile_.prototype.forDataAtCoordinate =
|
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) {
|
if (this.state == ol.TileState.IDLE && opt_noRequest !== true) {
|
||||||
this.listenOnce(goog.events.EventType.CHANGE, function(e) {
|
goog.events.listenOnce(this, goog.events.EventType.CHANGE, function(e) {
|
||||||
f.call(opt_this, this.getData(coordinate));
|
callback.call(opt_this, this.getData(coordinate));
|
||||||
}, false, this);
|
}, false, this);
|
||||||
this.loadInternal_();
|
this.loadInternal_();
|
||||||
} else {
|
} else {
|
||||||
f.call(opt_this, this.getData(coordinate));
|
callback.call(opt_this, this.getData(coordinate));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user