Add tests and documentation for ol.net.jsonp
ol.net.Jsonp was renamed to ol.net.jsonp, because it is not a constructor.
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
goog.provide('ol.net.Jsonp');
|
||||
goog.provide('ol.net');
|
||||
|
||||
|
||||
/**
|
||||
* Simple JSONP helper. Supports error callbacks and a custom callback param.
|
||||
* The error callback will be called when no JSONP is executed after 10 seconds.
|
||||
*
|
||||
* @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'.
|
||||
* @param {string=} opt_callbackParam Custom qurey parameter for the JSONP
|
||||
* callback. Default is 'callback'.
|
||||
*/
|
||||
ol.net.Jsonp = function(url, callback, opt_errback, opt_callbackParam) {
|
||||
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);
|
||||
var key = 'olc_' + goog.getUid(callback);
|
||||
script.src = url + (url.indexOf('?') == -1 ? '?' : '&') +
|
||||
(opt_callbackParam || 'callback') + '=' + key;
|
||||
var timer = goog.global.setTimeout(function() {
|
||||
|
||||
@@ -5,7 +5,7 @@ goog.require('ol.Attribution');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.net.Jsonp');
|
||||
goog.require('ol.net');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.State');
|
||||
goog.require('ol.source.TileImage');
|
||||
@@ -49,7 +49,7 @@ ol.source.BingMaps = function(options) {
|
||||
options.imagerySet +
|
||||
'?uriScheme=https&include=ImageryProviders&key=' + options.key;
|
||||
|
||||
ol.net.Jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined,
|
||||
ol.net.jsonp(url, this.handleImageryMetadataResponse.bind(this), undefined,
|
||||
'jsonp');
|
||||
|
||||
};
|
||||
|
||||
@@ -12,7 +12,7 @@ goog.require('ol.Attribution');
|
||||
goog.require('ol.TileRange');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.net.Jsonp');
|
||||
goog.require('ol.net');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.State');
|
||||
goog.require('ol.source.TileImage');
|
||||
@@ -40,7 +40,7 @@ ol.source.TileJSON = function(options) {
|
||||
});
|
||||
|
||||
if (options.jsonp) {
|
||||
ol.net.Jsonp(options.url, this.handleTileJSONResponse.bind(this),
|
||||
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this),
|
||||
this.handleTileJSONError.bind(this));
|
||||
} else {
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
@@ -9,7 +9,7 @@ goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.events');
|
||||
goog.require('ol.events.EventType');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.net.Jsonp');
|
||||
goog.require('ol.net');
|
||||
goog.require('ol.proj');
|
||||
goog.require('ol.source.State');
|
||||
goog.require('ol.source.Tile');
|
||||
@@ -49,7 +49,7 @@ ol.source.TileUTFGrid = function(options) {
|
||||
*/
|
||||
this.template_ = undefined;
|
||||
|
||||
ol.net.Jsonp(options.url, this.handleTileJSONResponse.bind(this));
|
||||
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this));
|
||||
};
|
||||
goog.inherits(ol.source.TileUTFGrid, ol.source.Tile);
|
||||
|
||||
@@ -359,7 +359,7 @@ ol.source.TileUTFGridTile_.prototype.handleLoad_ = function(json) {
|
||||
ol.source.TileUTFGridTile_.prototype.loadInternal_ = function() {
|
||||
if (this.state == ol.TileState.IDLE) {
|
||||
this.state = ol.TileState.LOADING;
|
||||
ol.net.Jsonp(this.src_, this.handleLoad_.bind(this),
|
||||
ol.net.jsonp(this.src_, this.handleLoad_.bind(this),
|
||||
this.handleError_.bind(this));
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user