Remove use of goog.bind and use ES5 .bind
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<link rel="stylesheet" href="./resources/layout.css" type="text/css">
|
||||
{{{ extraHead.local }}}
|
||||
{{{ css.tag }}}
|
||||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch"></script>
|
||||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=fetch,Function.prototype.bind|gated"></script>
|
||||
<script src="./resources/zeroclipboard/ZeroClipboard.min.js"></script>
|
||||
<title>{{ title }}</title>
|
||||
</head>
|
||||
|
||||
@@ -13,6 +13,7 @@ tags: "fullscreen, geolocation, orientation, mobile"
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" type="text/css">
|
||||
<link rel="stylesheet" href="../css/ol.css" type="text/css">
|
||||
<link rel="stylesheet" href="./resources/layout.css" type="text/css">
|
||||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Function.prototype.bind|gated"></script>
|
||||
<title>Mobile Geolocation Tracking with Orientation</title>
|
||||
<style type="text/css">
|
||||
html, body, .map {
|
||||
|
||||
@@ -13,6 +13,7 @@ cloak:
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
|
||||
<title>Mobile full screen example</title>
|
||||
<script src="https://cdn.polyfill.io/v2/polyfill.min.js?features=Function.prototype.bind|gated"></script>
|
||||
<style type="text/css">
|
||||
html, body, .map {
|
||||
margin: 0;
|
||||
|
||||
@@ -1763,8 +1763,8 @@ ol.format.KML.prototype.readDocumentOrFolder_ = function(node, objectStack) {
|
||||
'Document': ol.xml.makeArrayExtender(this.readDocumentOrFolder_, this),
|
||||
'Folder': ol.xml.makeArrayExtender(this.readDocumentOrFolder_, this),
|
||||
'Placemark': ol.xml.makeArrayPusher(this.readPlacemark_, this),
|
||||
'Style': goog.bind(this.readSharedStyle_, this),
|
||||
'StyleMap': goog.bind(this.readSharedStyleMap_, this)
|
||||
'Style': this.readSharedStyle_.bind(this),
|
||||
'StyleMap': this.readSharedStyleMap_.bind(this)
|
||||
});
|
||||
var features = ol.xml.pushParseAndPop(/** @type {Array.<ol.Feature>} */ ([]),
|
||||
parsersNS, node, objectStack, this);
|
||||
|
||||
@@ -135,8 +135,8 @@ ol.Geolocation.prototype.handleTrackingChanged_ = function() {
|
||||
var tracking = this.getTracking();
|
||||
if (tracking && this.watchId_ === undefined) {
|
||||
this.watchId_ = goog.global.navigator.geolocation.watchPosition(
|
||||
goog.bind(this.positionChange_, this),
|
||||
goog.bind(this.positionError_, this),
|
||||
this.positionChange_.bind(this),
|
||||
this.positionError_.bind(this),
|
||||
this.getTrackingOptions());
|
||||
} else if (!tracking && this.watchId_ !== undefined) {
|
||||
goog.global.navigator.geolocation.clearWatch(this.watchId_);
|
||||
|
||||
@@ -80,7 +80,7 @@ ol.ImageCanvas.prototype.load = function() {
|
||||
goog.asserts.assert(this.loader_, 'this.loader_ must be set');
|
||||
this.state = ol.ImageState.LOADING;
|
||||
this.changed();
|
||||
this.loader_(goog.bind(this.handleLoad_, this));
|
||||
this.loader_(this.handleLoad_.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ ol.interaction.MouseWheelZoom.handleEvent = function(mapBrowserEvent) {
|
||||
|
||||
goog.global.clearTimeout(this.timeoutId_);
|
||||
this.timeoutId_ = goog.global.setTimeout(
|
||||
goog.bind(this.doZoom_, this, map), timeLeft);
|
||||
this.doZoom_.bind(this, map), timeLeft);
|
||||
|
||||
mapBrowserEvent.preventDefault();
|
||||
stopEvent = true;
|
||||
|
||||
@@ -120,7 +120,7 @@ ol.interaction.Snap = function(opt_options) {
|
||||
* @type {function(ol.interaction.Snap.SegmentDataType, ol.interaction.Snap.SegmentDataType): number}
|
||||
* @private
|
||||
*/
|
||||
this.sortByDistance_ = goog.bind(ol.interaction.Snap.sortByDistance, this);
|
||||
this.sortByDistance_ = ol.interaction.Snap.sortByDistance.bind(this);
|
||||
|
||||
|
||||
/**
|
||||
@@ -170,7 +170,7 @@ ol.interaction.Snap.prototype.addFeature = function(feature, opt_listen) {
|
||||
if (listen) {
|
||||
this.geometryModifyListenerKeys_[feature_uid] = geometry.on(
|
||||
goog.events.EventType.CHANGE,
|
||||
goog.bind(this.handleGeometryModify_, this, feature),
|
||||
this.handleGeometryModify_.bind(this, feature),
|
||||
this);
|
||||
this.geometryChangeListenerKeys_[feature_uid] = feature.on(
|
||||
ol.Object.getChangeEventType(feature.getGeometryName()),
|
||||
|
||||
@@ -102,7 +102,7 @@ ol.layer.Heatmap = function(opt_options) {
|
||||
goog.asserts.assert(goog.isFunction(weightFunction),
|
||||
'weightFunction should be a function');
|
||||
|
||||
this.setStyle(goog.bind(function(feature, resolution) {
|
||||
this.setStyle(function(feature, resolution) {
|
||||
goog.asserts.assert(this.styleCache_, 'this.styleCache_ expected');
|
||||
goog.asserts.assert(this.circleImage_ !== undefined,
|
||||
'this.circleImage_ should be defined');
|
||||
@@ -123,7 +123,7 @@ ol.layer.Heatmap = function(opt_options) {
|
||||
this.styleCache_[index] = style;
|
||||
}
|
||||
return style;
|
||||
}, this));
|
||||
}.bind(this));
|
||||
|
||||
// For performance reasons, don't sort the features before rendering.
|
||||
// The render order is not relevant for a heatmap representation.
|
||||
|
||||
@@ -392,8 +392,8 @@ ol.Map = function(options) {
|
||||
* @type {ol.TileQueue}
|
||||
*/
|
||||
this.tileQueue_ = new ol.TileQueue(
|
||||
goog.bind(this.getTilePriority, this),
|
||||
goog.bind(this.handleTileChange_, this));
|
||||
this.getTilePriority.bind(this),
|
||||
this.handleTileChange_.bind(this));
|
||||
|
||||
/**
|
||||
* Uids of features to skip at rendering time.
|
||||
|
||||
@@ -236,12 +236,12 @@ ol.MapBrowserEventHandler.prototype.emulateClick_ = function(pointerEvent) {
|
||||
this.dispatchEvent(newEvent);
|
||||
} else {
|
||||
// click
|
||||
this.clickTimeoutId_ = goog.global.setTimeout(goog.bind(function() {
|
||||
this.clickTimeoutId_ = goog.global.setTimeout(function() {
|
||||
this.clickTimeoutId_ = 0;
|
||||
var newEvent = new ol.MapBrowserPointerEvent(
|
||||
ol.MapBrowserEvent.EventType.SINGLECLICK, this.map_, pointerEvent);
|
||||
this.dispatchEvent(newEvent);
|
||||
}, this), 250);
|
||||
}.bind(this), 250);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -120,7 +120,7 @@ ol.pointer.PointerEventHandler.prototype.registerSource = function(name, source)
|
||||
var handler = s.getHandlerForEvent(e);
|
||||
|
||||
if (handler) {
|
||||
this.eventMap_[e] = goog.bind(handler, s);
|
||||
this.eventMap_[e] = handler.bind(s);
|
||||
}
|
||||
}, this);
|
||||
this.eventSourceList_.push(s);
|
||||
|
||||
@@ -150,7 +150,7 @@ ol.pointer.TouchSource.prototype.removePrimaryPointer_ = function(inPointer) {
|
||||
*/
|
||||
ol.pointer.TouchSource.prototype.resetClickCount_ = function() {
|
||||
this.resetId_ = goog.global.setTimeout(
|
||||
goog.bind(this.resetClickCountHandler_, this),
|
||||
this.resetClickCountHandler_.bind(this),
|
||||
ol.pointer.TouchSource.CLICK_COUNT_TIMEOUT);
|
||||
};
|
||||
|
||||
|
||||
@@ -368,7 +368,7 @@ ol.renderer.Map.prototype.scheduleRemoveUnusedLayerRenderers = function(frameSta
|
||||
for (layerKey in this.layerRenderers_) {
|
||||
if (!(layerKey in frameState.layerStates)) {
|
||||
frameState.postRenderFunctions.push(
|
||||
goog.bind(this.removeUnusedLayerRenderers_, this));
|
||||
this.removeUnusedLayerRenderers_.bind(this));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,20 +128,19 @@ ol.renderer.webgl.Map = function(container, map) {
|
||||
* @type {ol.structs.PriorityQueue.<Array>}
|
||||
*/
|
||||
this.tileTextureQueue_ = new ol.structs.PriorityQueue(
|
||||
goog.bind(
|
||||
/**
|
||||
* @param {Array.<*>} element Element.
|
||||
* @return {number} Priority.
|
||||
* @this {ol.renderer.webgl.Map}
|
||||
*/
|
||||
function(element) {
|
||||
var tileCenter = /** @type {ol.Coordinate} */ (element[1]);
|
||||
var tileResolution = /** @type {number} */ (element[2]);
|
||||
var deltaX = tileCenter[0] - this.focus_[0];
|
||||
var deltaY = tileCenter[1] - this.focus_[1];
|
||||
return 65536 * Math.log(tileResolution) +
|
||||
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
|
||||
}, this),
|
||||
/**
|
||||
* @param {Array.<*>} element Element.
|
||||
* @return {number} Priority.
|
||||
* @this {ol.renderer.webgl.Map}
|
||||
*/
|
||||
(function(element) {
|
||||
var tileCenter = /** @type {ol.Coordinate} */ (element[1]);
|
||||
var tileResolution = /** @type {number} */ (element[2]);
|
||||
var deltaX = tileCenter[0] - this.focus_[0];
|
||||
var deltaY = tileCenter[1] - this.focus_[1];
|
||||
return 65536 * Math.log(tileResolution) +
|
||||
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
|
||||
}).bind(this),
|
||||
/**
|
||||
* @param {Array.<*>} element Element.
|
||||
* @return {string} Key.
|
||||
@@ -150,11 +149,14 @@ ol.renderer.webgl.Map = function(container, map) {
|
||||
return /** @type {ol.Tile} */ (element[0]).getKey();
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @type {ol.PostRenderFunction}
|
||||
*/
|
||||
this.loadNextTileTexture_ = goog.bind(
|
||||
|
||||
/**
|
||||
* @param {ol.Map} map Map.
|
||||
* @param {?olx.FrameState} frameState Frame state.
|
||||
* @return {boolean} false.
|
||||
* @this {ol.renderer.webgl.Map}
|
||||
*/
|
||||
this.loadNextTileTexture_ =
|
||||
function(map, frameState) {
|
||||
if (!this.tileTextureQueue_.isEmpty()) {
|
||||
this.tileTextureQueue_.reprioritize();
|
||||
@@ -165,7 +167,9 @@ ol.renderer.webgl.Map = function(container, map) {
|
||||
this.bindTileTexture(
|
||||
tile, tileSize, tileGutter, goog.webgl.LINEAR, goog.webgl.LINEAR);
|
||||
}
|
||||
}, this);
|
||||
return false;
|
||||
}.bind(this);
|
||||
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -514,7 +518,7 @@ ol.renderer.webgl.Map.prototype.renderFrame = function(frameState) {
|
||||
|
||||
if (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ >
|
||||
ol.WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) {
|
||||
frameState.postRenderFunctions.push(goog.bind(this.expireCache_, this));
|
||||
frameState.postRenderFunctions.push(this.expireCache_.bind(this));
|
||||
}
|
||||
|
||||
if (!this.tileTextureQueue_.isEmpty()) {
|
||||
|
||||
@@ -321,7 +321,7 @@ ol.reproj.Tile.prototype.load = function() {
|
||||
});
|
||||
|
||||
if (leftToLoad === 0) {
|
||||
goog.global.setTimeout(goog.bind(this.reproject_, this), 0);
|
||||
goog.global.setTimeout(this.reproject_.bind(this), 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -55,7 +55,7 @@ ol.source.BingMaps = function(options) {
|
||||
'include': 'ImageryProviders',
|
||||
'uriScheme': 'https',
|
||||
'key': options.key
|
||||
}, goog.bind(this.handleImageryMetadataResponse, this));
|
||||
}, this.handleImageryMetadataResponse.bind(this));
|
||||
|
||||
};
|
||||
goog.inherits(ol.source.BingMaps, ol.source.TileImage);
|
||||
|
||||
@@ -130,10 +130,10 @@ ol.source.Image.prototype.getImage = function(extent, resolution, pixelRatio, pr
|
||||
|
||||
this.reprojectedImage_ = new ol.reproj.Image(
|
||||
sourceProjection, projection, extent, resolution, pixelRatio,
|
||||
goog.bind(function(extent, resolution, pixelRatio) {
|
||||
function(extent, resolution, pixelRatio) {
|
||||
return this.getImageInternal(extent, resolution,
|
||||
pixelRatio, sourceProjection);
|
||||
}, this));
|
||||
}.bind(this));
|
||||
this.reprojectedRevision_ = this.getRevision();
|
||||
|
||||
return this.reprojectedImage_;
|
||||
|
||||
@@ -65,7 +65,7 @@ ol.source.ImageVector = function(options) {
|
||||
|
||||
goog.base(this, {
|
||||
attributions: options.attributions,
|
||||
canvasFunction: goog.bind(this.canvasFunctionInternal_, this),
|
||||
canvasFunction: this.canvasFunctionInternal_.bind(this),
|
||||
logo: options.logo,
|
||||
projection: options.projection,
|
||||
ratio: options.ratio,
|
||||
|
||||
@@ -80,7 +80,7 @@ ol.source.Raster = function(options) {
|
||||
function() {
|
||||
return 1;
|
||||
},
|
||||
goog.bind(this.changed, this));
|
||||
this.changed.bind(this));
|
||||
|
||||
var layerStatesArray = ol.source.Raster.getLayerStatesArray_(this.renderers_);
|
||||
var layerStates = {};
|
||||
|
||||
@@ -42,7 +42,7 @@ ol.source.TileArcGISRest = function(opt_options) {
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileGrid: options.tileGrid,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
tileUrlFunction: goog.bind(this.tileUrlFunction_, this),
|
||||
tileUrlFunction: this.tileUrlFunction_.bind(this),
|
||||
url: options.url,
|
||||
urls: options.urls,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
|
||||
@@ -229,9 +229,9 @@ ol.source.TileImage.prototype.getTile = function(z, x, y, pixelRatio, projection
|
||||
sourceProjection, sourceTileGrid,
|
||||
projection, targetTileGrid,
|
||||
tileCoord, wrappedTileCoord, this.getTilePixelRatio(pixelRatio),
|
||||
goog.bind(function(z, x, y, pixelRatio) {
|
||||
function(z, x, y, pixelRatio) {
|
||||
return this.getTileInternal(z, x, y, pixelRatio, sourceProjection);
|
||||
}, this), this.reprojectionErrorThreshold_,
|
||||
}.bind(this), this.reprojectionErrorThreshold_,
|
||||
this.renderReprojectionEdges_);
|
||||
|
||||
cache.set(tileCoordKey, tile);
|
||||
|
||||
@@ -45,8 +45,8 @@ ol.source.TileJSON = function(options) {
|
||||
|
||||
if (options.jsonp) {
|
||||
var request = new goog.net.Jsonp(options.url);
|
||||
request.send(undefined, goog.bind(this.handleTileJSONResponse, this),
|
||||
goog.bind(this.handleTileJSONError, this));
|
||||
request.send(undefined, this.handleTileJSONResponse.bind(this),
|
||||
this.handleTileJSONError.bind(this));
|
||||
} else {
|
||||
var xhr = new goog.net.XhrIo(new goog.net.CorsXmlHttpFactory());
|
||||
goog.events.listen(xhr, goog.net.EventType.COMPLETE, function(e) {
|
||||
|
||||
@@ -50,7 +50,7 @@ ol.source.TileUTFGrid = function(options) {
|
||||
this.template_ = undefined;
|
||||
|
||||
var request = new goog.net.Jsonp(options.url);
|
||||
request.send(undefined, goog.bind(this.handleTileJSONResponse, this));
|
||||
request.send(undefined, this.handleTileJSONResponse.bind(this));
|
||||
};
|
||||
goog.inherits(ol.source.TileUTFGrid, ol.source.Tile);
|
||||
|
||||
@@ -361,8 +361,8 @@ ol.source.TileUTFGridTile_.prototype.loadInternal_ = function() {
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
var request = new goog.net.Jsonp(this.src_);
|
||||
request.send(undefined, goog.bind(this.handleLoad_, this),
|
||||
goog.bind(this.handleError_, this));
|
||||
request.send(undefined, this.handleLoad_.bind(this),
|
||||
this.handleError_.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ ol.source.TileWMS = function(opt_options) {
|
||||
reprojectionErrorThreshold: options.reprojectionErrorThreshold,
|
||||
tileGrid: options.tileGrid,
|
||||
tileLoadFunction: options.tileLoadFunction,
|
||||
tileUrlFunction: goog.bind(this.tileUrlFunction_, this),
|
||||
tileUrlFunction: this.tileUrlFunction_.bind(this),
|
||||
url: options.url,
|
||||
urls: options.urls,
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
|
||||
@@ -291,12 +291,12 @@ ol.style.Circle.prototype.render_ = function(atlasManager) {
|
||||
if (hasCustomHitDetectionImage) {
|
||||
// render the hit-detection image into a separate atlas image
|
||||
renderHitDetectionCallback =
|
||||
goog.bind(this.drawHitDetectionCanvas_, this, renderOptions);
|
||||
this.drawHitDetectionCanvas_.bind(this, renderOptions);
|
||||
}
|
||||
|
||||
var id = this.getChecksum();
|
||||
var info = atlasManager.add(
|
||||
id, size, size, goog.bind(this.draw_, this, renderOptions),
|
||||
id, size, size, this.draw_.bind(this, renderOptions),
|
||||
renderHitDetectionCallback);
|
||||
goog.asserts.assert(info, 'circle radius is too large');
|
||||
|
||||
|
||||
@@ -371,12 +371,12 @@ ol.style.RegularShape.prototype.render_ = function(atlasManager) {
|
||||
if (hasCustomHitDetectionImage) {
|
||||
// render the hit-detection image into a separate atlas image
|
||||
renderHitDetectionCallback =
|
||||
goog.bind(this.drawHitDetectionCanvas_, this, renderOptions);
|
||||
this.drawHitDetectionCanvas_.bind(this, renderOptions);
|
||||
}
|
||||
|
||||
var id = this.getChecksum();
|
||||
var info = atlasManager.add(
|
||||
id, size, size, goog.bind(this.draw_, this, renderOptions),
|
||||
id, size, size, this.draw_.bind(this, renderOptions),
|
||||
renderHitDetectionCallback);
|
||||
goog.asserts.assert(info, 'shape size is too large');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user