Remove goog.net.* and goog.async.AnimationDelay
This commit is contained in:
2
Makefile
2
Makefile
@@ -181,7 +181,7 @@ build/timestamps/check-%-timestamp: $(BUILD_HOSTED)/examples/%.html \
|
|||||||
$(BUILD_HOSTED)/build/ol.js \
|
$(BUILD_HOSTED)/build/ol.js \
|
||||||
$(BUILD_HOSTED)/css/ol.css
|
$(BUILD_HOSTED)/css/ol.css
|
||||||
@mkdir -p $(@D)
|
@mkdir -p $(@D)
|
||||||
./node_modules/.bin/phantomjs --ssl-protocol=any --ignore-ssl-errors=true bin/check-example.js $<
|
./node_modules/.bin/phantomjs --local-to-remote-url-access=true --ssl-protocol=any --ignore-ssl-errors=true bin/check-example.js $<
|
||||||
@touch $@
|
@touch $@
|
||||||
|
|
||||||
build/timestamps/check-requires-timestamp: $(SRC_JS) $(EXAMPLES_JS) \
|
build/timestamps/check-requires-timestamp: $(SRC_JS) $(EXAMPLES_JS) \
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ ol.events.condition.click = function(mapBrowserEvent) {
|
|||||||
ol.events.condition.mouseActionButton = function(mapBrowserEvent) {
|
ol.events.condition.mouseActionButton = function(mapBrowserEvent) {
|
||||||
var browserEvent = mapBrowserEvent.originalEvent;
|
var browserEvent = mapBrowserEvent.originalEvent;
|
||||||
return browserEvent.button == 0 &&
|
return browserEvent.button == 0 &&
|
||||||
!(goog.userAgent.WEBKIT && goog.userAgent.MAC && browserEvent.ctrlKey);
|
!(goog.userAgent.WEBKIT && ol.has.MAC && browserEvent.ctrlKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -168,7 +168,7 @@ ol.events.condition.platformModifierKeyOnly = function(mapBrowserEvent) {
|
|||||||
var browserEvent = mapBrowserEvent.originalEvent;
|
var browserEvent = mapBrowserEvent.originalEvent;
|
||||||
return (
|
return (
|
||||||
!browserEvent.altKey &&
|
!browserEvent.altKey &&
|
||||||
(goog.userAgent.MAC ? browserEvent.metaKey : browserEvent.ctrlKey) &&
|
(ol.has.MAC ? browserEvent.metaKey : browserEvent.ctrlKey) &&
|
||||||
!browserEvent.shiftKey);
|
!browserEvent.shiftKey);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ goog.provide('ol.FeatureUrlFunction');
|
|||||||
goog.provide('ol.featureloader');
|
goog.provide('ol.featureloader');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('ol.events');
|
|
||||||
goog.require('goog.net.EventType');
|
|
||||||
goog.require('goog.net.XhrIo');
|
|
||||||
goog.require('goog.net.XhrIo.ResponseType');
|
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
goog.require('ol.VectorTile');
|
goog.require('ol.VectorTile');
|
||||||
goog.require('ol.format.FormatType');
|
goog.require('ol.format.FormatType');
|
||||||
@@ -67,38 +63,31 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
|||||||
* @this {ol.source.Vector|ol.VectorTile}
|
* @this {ol.source.Vector|ol.VectorTile}
|
||||||
*/
|
*/
|
||||||
function(extent, resolution, projection) {
|
function(extent, resolution, projection) {
|
||||||
var xhrIo = new goog.net.XhrIo();
|
var xhr = new XMLHttpRequest();
|
||||||
xhrIo.setResponseType(
|
xhr.open('GET',
|
||||||
format.getType() == ol.format.FormatType.ARRAY_BUFFER ?
|
goog.isFunction(url) ? url(extent, resolution, projection) : url);
|
||||||
goog.net.XhrIo.ResponseType.ARRAY_BUFFER :
|
if (format.getType() == ol.format.FormatType.ARRAY_BUFFER) {
|
||||||
goog.net.XhrIo.ResponseType.TEXT);
|
xhr.responseType = 'arraybuffer';
|
||||||
ol.events.listen(xhrIo, goog.net.EventType.COMPLETE,
|
}
|
||||||
/**
|
/**
|
||||||
* @param {Event} event Event.
|
* @param {Event} event Event.
|
||||||
* @private
|
* @private
|
||||||
* @this {ol.source.Vector}
|
|
||||||
*/
|
*/
|
||||||
function(event) {
|
xhr.onload = function(event) {
|
||||||
var xhrIo = event.target;
|
if (xhr.status < 400) {
|
||||||
goog.asserts.assertInstanceof(xhrIo, goog.net.XhrIo,
|
|
||||||
'event.target/xhrIo is an instance of goog.net.XhrIo');
|
|
||||||
if (xhrIo.isSuccess()) {
|
|
||||||
var type = format.getType();
|
var type = format.getType();
|
||||||
/** @type {Document|Node|Object|string|undefined} */
|
/** @type {Document|Node|Object|string|undefined} */
|
||||||
var source;
|
var source;
|
||||||
if (type == ol.format.FormatType.JSON) {
|
if (type == ol.format.FormatType.JSON ||
|
||||||
source = xhrIo.getResponseText();
|
type == ol.format.FormatType.TEXT) {
|
||||||
} else if (type == ol.format.FormatType.TEXT) {
|
source = /** @type {string} */ (xhr.responseText);
|
||||||
source = xhrIo.getResponseText();
|
|
||||||
} else if (type == ol.format.FormatType.XML) {
|
} else if (type == ol.format.FormatType.XML) {
|
||||||
if (!goog.userAgent.IE) {
|
source = xhr.responseXML;
|
||||||
source = xhrIo.getResponseXml();
|
|
||||||
}
|
|
||||||
if (!source) {
|
if (!source) {
|
||||||
source = ol.xml.parse(xhrIo.getResponseText());
|
source = ol.xml.parse(xhr.responseText);
|
||||||
}
|
}
|
||||||
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
} else if (type == ol.format.FormatType.ARRAY_BUFFER) {
|
||||||
source = xhrIo.getResponse();
|
source = /** @type {ArrayBuffer} */ (xhr.response);
|
||||||
} else {
|
} else {
|
||||||
goog.asserts.fail('unexpected format type');
|
goog.asserts.fail('unexpected format type');
|
||||||
}
|
}
|
||||||
@@ -112,14 +101,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
|||||||
} else {
|
} else {
|
||||||
failure.call(this);
|
failure.call(this);
|
||||||
}
|
}
|
||||||
goog.dispose(xhrIo);
|
}.bind(this);
|
||||||
}, false, this);
|
xhr.send();
|
||||||
if (goog.isFunction(url)) {
|
|
||||||
xhrIo.send(url(extent, resolution, projection));
|
|
||||||
} else {
|
|
||||||
xhrIo.send(url);
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,12 @@ ol.has.FIREFOX = ua.indexOf('firefox') !== -1;
|
|||||||
*/
|
*/
|
||||||
ol.has.SAFARI = ua.indexOf('safari') !== -1 && ua.indexOf('chrom') === -1;
|
ol.has.SAFARI = ua.indexOf('safari') !== -1 && ua.indexOf('chrom') === -1;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* User agent string says we are dealing with a Mac as platform.
|
||||||
|
* @type {boolean}
|
||||||
|
*/
|
||||||
|
ol.has.MAC = ua.indexOf('Macintosh') !== -1;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The ratio between physical pixels and device-independent pixels
|
* The ratio between physical pixels and device-independent pixels
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ goog.provide('ol.Map');
|
|||||||
goog.provide('ol.MapProperty');
|
goog.provide('ol.MapProperty');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.async.AnimationDelay');
|
|
||||||
goog.require('goog.async.nextTick');
|
goog.require('goog.async.nextTick');
|
||||||
goog.require('goog.debug.Console');
|
goog.require('goog.debug.Console');
|
||||||
goog.require('goog.dom');
|
goog.require('goog.dom');
|
||||||
@@ -199,11 +198,17 @@ ol.Map = function(options) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {goog.async.AnimationDelay}
|
* @type {number|undefined}
|
||||||
*/
|
*/
|
||||||
this.animationDelay_ =
|
this.animationDelayKey_;
|
||||||
new goog.async.AnimationDelay(this.renderFrame_, undefined, this);
|
|
||||||
this.registerDisposable(this.animationDelay_);
|
/**
|
||||||
|
* @private
|
||||||
|
*/
|
||||||
|
this.animationDelay_ = function() {
|
||||||
|
this.animationDelayKey_ = undefined;
|
||||||
|
this.renderFrame_.call(this, Date.now());
|
||||||
|
}.bind(this);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
@@ -1200,7 +1205,10 @@ ol.Map.prototype.isRendered = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.renderSync = function() {
|
ol.Map.prototype.renderSync = function() {
|
||||||
this.animationDelay_.fire();
|
if (this.animationDelayKey_) {
|
||||||
|
goog.global.cancelAnimationFrame(this.animationDelayKey_);
|
||||||
|
}
|
||||||
|
this.animationDelay_();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -1209,8 +1217,9 @@ ol.Map.prototype.renderSync = function() {
|
|||||||
* @api stable
|
* @api stable
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.render = function() {
|
ol.Map.prototype.render = function() {
|
||||||
if (!this.animationDelay_.isActive()) {
|
if (this.animationDelayKey_ === undefined) {
|
||||||
this.animationDelay_.start();
|
this.animationDelayKey_ = goog.global.requestAnimationFrame(
|
||||||
|
this.animationDelay_);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
29
src/ol/net.js
Normal file
29
src/ol/net.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
goog.provide('ol.net.Jsonp');
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param {string} url Request url. A 'callback' query parameter will be
|
||||||
|
* appended.
|
||||||
|
* @param {Function} callback Callback on success.
|
||||||
|
* @param {function()=} opt_errback Callback on error.
|
||||||
|
* @param {string=} opt_callbackParam Callback parameter. Default is 'callback'.
|
||||||
|
*/
|
||||||
|
ol.net.Jsonp = function(url, callback, opt_errback, opt_callbackParam) {
|
||||||
|
var script = goog.global.document.createElement('script');
|
||||||
|
script.async = true;
|
||||||
|
var key = 'ol_callback_' + goog.getUid(callback);
|
||||||
|
script.src = url + (url.indexOf('?') == -1 ? '?' : '&') +
|
||||||
|
(opt_callbackParam || 'callback') + '=' + key;
|
||||||
|
var timer = goog.global.setTimeout(function() {
|
||||||
|
delete goog.global[key];
|
||||||
|
if (opt_errback) {
|
||||||
|
opt_errback();
|
||||||
|
}
|
||||||
|
}, 10000);
|
||||||
|
goog.global[key] = function(data) {
|
||||||
|
goog.global.clearTimeout(timer);
|
||||||
|
delete goog.global[key];
|
||||||
|
callback(data);
|
||||||
|
};
|
||||||
|
goog.global.document.getElementsByTagName('head')[0].appendChild(script);
|
||||||
|
};
|
||||||
@@ -1,12 +1,11 @@
|
|||||||
goog.provide('ol.source.BingMaps');
|
goog.provide('ol.source.BingMaps');
|
||||||
|
|
||||||
goog.require('goog.Uri');
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.net.Jsonp');
|
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.TileRange');
|
goog.require('ol.TileRange');
|
||||||
goog.require('ol.TileUrlFunction');
|
goog.require('ol.TileUrlFunction');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.net.Jsonp');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.State');
|
goog.require('ol.source.State');
|
||||||
goog.require('ol.source.TileImage');
|
goog.require('ol.source.TileImage');
|
||||||
@@ -46,16 +45,12 @@ ol.source.BingMaps = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.maxZoom_ = options.maxZoom !== undefined ? options.maxZoom : -1;
|
this.maxZoom_ = options.maxZoom !== undefined ? options.maxZoom : -1;
|
||||||
|
|
||||||
var uri = new goog.Uri(
|
var url = 'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
|
||||||
'https://dev.virtualearth.net/REST/v1/Imagery/Metadata/' +
|
options.imagerySet +
|
||||||
options.imagerySet);
|
'?uriScheme=https&include=ImageryProviders&key=' + options.key;
|
||||||
|
|
||||||
var jsonp = new goog.net.Jsonp(uri, 'jsonp');
|
ol.net.Jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined,
|
||||||
jsonp.send({
|
'jsonp');
|
||||||
'include': 'ImageryProviders',
|
|
||||||
'uriScheme': 'https',
|
|
||||||
'key': options.key
|
|
||||||
}, this.handleImageryMetadataResponse.bind(this));
|
|
||||||
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.source.BingMaps, ol.source.TileImage);
|
goog.inherits(ol.source.BingMaps, ol.source.TileImage);
|
||||||
|
|||||||
@@ -8,15 +8,11 @@ goog.provide('ol.source.TileJSON');
|
|||||||
goog.provide('ol.tilejson');
|
goog.provide('ol.tilejson');
|
||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('ol.events');
|
|
||||||
goog.require('goog.net.CorsXmlHttpFactory');
|
|
||||||
goog.require('goog.net.EventType');
|
|
||||||
goog.require('goog.net.Jsonp');
|
|
||||||
goog.require('goog.net.XhrIo');
|
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.TileRange');
|
goog.require('ol.TileRange');
|
||||||
goog.require('ol.TileUrlFunction');
|
goog.require('ol.TileUrlFunction');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.net.Jsonp');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.State');
|
goog.require('ol.source.State');
|
||||||
goog.require('ol.source.TileImage');
|
goog.require('ol.source.TileImage');
|
||||||
@@ -44,21 +40,20 @@ ol.source.TileJSON = function(options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (options.jsonp) {
|
if (options.jsonp) {
|
||||||
var request = new goog.net.Jsonp(options.url);
|
ol.net.Jsonp(options.url, this.handleTileJSONResponse.bind(this),
|
||||||
request.send(undefined, this.handleTileJSONResponse.bind(this),
|
|
||||||
this.handleTileJSONError.bind(this));
|
this.handleTileJSONError.bind(this));
|
||||||
} else {
|
} else {
|
||||||
var xhr = new goog.net.XhrIo(new goog.net.CorsXmlHttpFactory());
|
var xhr = new XMLHttpRequest();
|
||||||
ol.events.listen(xhr, goog.net.EventType.COMPLETE, function(e) {
|
xhr.open('GET', options.url);
|
||||||
if (xhr.isSuccess()) {
|
xhr.onload = function(e) {
|
||||||
var response = /** @type {TileJSON} */(xhr.getResponseJson());
|
if (xhr.status < 400) {
|
||||||
|
var response = /** @type {TileJSON} */(JSON.parse(xhr.responseText));
|
||||||
this.handleTileJSONResponse(response);
|
this.handleTileJSONResponse(response);
|
||||||
} else {
|
} else {
|
||||||
this.handleTileJSONError();
|
this.handleTileJSONError();
|
||||||
}
|
}
|
||||||
xhr.dispose();
|
}.bind(this);
|
||||||
}, false, this);
|
xhr.send();
|
||||||
xhr.send(options.url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,9 +2,6 @@ goog.provide('ol.source.TileUTFGrid');
|
|||||||
|
|
||||||
goog.require('goog.asserts');
|
goog.require('goog.asserts');
|
||||||
goog.require('goog.async.nextTick');
|
goog.require('goog.async.nextTick');
|
||||||
goog.require('ol.events');
|
|
||||||
goog.require('ol.events.EventType');
|
|
||||||
goog.require('goog.net.Jsonp');
|
|
||||||
goog.require('ol.Attribution');
|
goog.require('ol.Attribution');
|
||||||
goog.require('ol.Tile');
|
goog.require('ol.Tile');
|
||||||
goog.require('ol.TileState');
|
goog.require('ol.TileState');
|
||||||
@@ -12,6 +9,7 @@ goog.require('ol.TileUrlFunction');
|
|||||||
goog.require('ol.events');
|
goog.require('ol.events');
|
||||||
goog.require('ol.events.EventType');
|
goog.require('ol.events.EventType');
|
||||||
goog.require('ol.extent');
|
goog.require('ol.extent');
|
||||||
|
goog.require('ol.net.Jsonp');
|
||||||
goog.require('ol.proj');
|
goog.require('ol.proj');
|
||||||
goog.require('ol.source.State');
|
goog.require('ol.source.State');
|
||||||
goog.require('ol.source.Tile');
|
goog.require('ol.source.Tile');
|
||||||
@@ -51,8 +49,7 @@ ol.source.TileUTFGrid = function(options) {
|
|||||||
*/
|
*/
|
||||||
this.template_ = undefined;
|
this.template_ = undefined;
|
||||||
|
|
||||||
var request = new goog.net.Jsonp(options.url);
|
ol.net.Jsonp(options.url, this.handleTileJSONResponse.bind(this));
|
||||||
request.send(undefined, this.handleTileJSONResponse.bind(this));
|
|
||||||
};
|
};
|
||||||
goog.inherits(ol.source.TileUTFGrid, ol.source.Tile);
|
goog.inherits(ol.source.TileUTFGrid, ol.source.Tile);
|
||||||
|
|
||||||
@@ -362,8 +359,7 @@ ol.source.TileUTFGridTile_.prototype.handleLoad_ = function(json) {
|
|||||||
ol.source.TileUTFGridTile_.prototype.loadInternal_ = function() {
|
ol.source.TileUTFGridTile_.prototype.loadInternal_ = function() {
|
||||||
if (this.state == ol.TileState.IDLE) {
|
if (this.state == ol.TileState.IDLE) {
|
||||||
this.state = ol.TileState.LOADING;
|
this.state = ol.TileState.LOADING;
|
||||||
var request = new goog.net.Jsonp(this.src_);
|
ol.net.Jsonp(this.src_, this.handleLoad_.bind(this),
|
||||||
request.send(undefined, this.handleLoad_.bind(this),
|
|
||||||
this.handleError_.bind(this));
|
this.handleError_.bind(this));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -7,11 +7,9 @@ describe('ol.source.BingMaps', function() {
|
|||||||
var source, tileGrid;
|
var source, tileGrid;
|
||||||
|
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
var googNetJsonp = goog.net.Jsonp;
|
var olNetJsonp = ol.net.Jsonp;
|
||||||
// mock goog.net.Jsonp (used in the ol.source.TileJSON constructor)
|
// mock ol.net.Jsonp (used in the ol.source.TileJSON constructor)
|
||||||
goog.net.Jsonp = function() {
|
ol.net.Jsonp = function(url, callback) {
|
||||||
this.send = function() {
|
|
||||||
var callback = arguments[1];
|
|
||||||
var client = new XMLHttpRequest();
|
var client = new XMLHttpRequest();
|
||||||
client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true);
|
client.open('GET', 'spec/ol/data/bing_aerialwithlabels.json', true);
|
||||||
client.onload = function() {
|
client.onload = function() {
|
||||||
@@ -19,12 +17,11 @@ describe('ol.source.BingMaps', function() {
|
|||||||
};
|
};
|
||||||
client.send();
|
client.send();
|
||||||
};
|
};
|
||||||
};
|
|
||||||
source = new ol.source.BingMaps({
|
source = new ol.source.BingMaps({
|
||||||
imagerySet: 'AerialWithLabels',
|
imagerySet: 'AerialWithLabels',
|
||||||
key: ''
|
key: ''
|
||||||
});
|
});
|
||||||
goog.net.Jsonp = googNetJsonp;
|
ol.net.Jsonp = olNetJsonp;
|
||||||
var key = source.on('change', function() {
|
var key = source.on('change', function() {
|
||||||
if (source.getState() === 'ready') {
|
if (source.getState() === 'ready') {
|
||||||
ol.Observable.unByKey(key);
|
ol.Observable.unByKey(key);
|
||||||
@@ -75,7 +72,7 @@ describe('ol.source.BingMaps', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
goog.require('goog.net.Jsonp');
|
goog.require('ol.net.Jsonp');
|
||||||
goog.require('ol.source.BingMaps');
|
goog.require('ol.source.BingMaps');
|
||||||
goog.require('ol.tilecoord');
|
goog.require('ol.tilecoord');
|
||||||
goog.require('ol.Observable');
|
goog.require('ol.Observable');
|
||||||
|
|||||||
Reference in New Issue
Block a user