Add tileJSON option to ol.source.TileJSON
This commit is contained in:
@@ -9,6 +9,7 @@ goog.provide('ol.source.TileJSON');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Attribution');
|
||||
goog.require('ol.TileUrlFunction');
|
||||
goog.require('ol.asserts');
|
||||
goog.require('ol.extent');
|
||||
goog.require('ol.net');
|
||||
goog.require('ol.proj');
|
||||
@@ -45,15 +46,21 @@ ol.source.TileJSON = function(options) {
|
||||
wrapX: options.wrapX !== undefined ? options.wrapX : true
|
||||
});
|
||||
|
||||
if (options.jsonp) {
|
||||
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this),
|
||||
this.handleTileJSONError.bind(this));
|
||||
if (options.url) {
|
||||
if (options.jsonp) {
|
||||
ol.net.jsonp(options.url, this.handleTileJSONResponse.bind(this),
|
||||
this.handleTileJSONError.bind(this));
|
||||
} else {
|
||||
var client = new XMLHttpRequest();
|
||||
client.addEventListener('load', this.onXHRLoad_.bind(this));
|
||||
client.addEventListener('error', this.onXHRError_.bind(this));
|
||||
client.open('GET', options.url);
|
||||
client.send();
|
||||
}
|
||||
} else if (options.tileJSON) {
|
||||
this.handleTileJSONResponse(options.tileJSON);
|
||||
} else {
|
||||
var client = new XMLHttpRequest();
|
||||
client.addEventListener('load', this.onXHRLoad_.bind(this));
|
||||
client.addEventListener('error', this.onXHRError_.bind(this));
|
||||
client.open('GET', options.url);
|
||||
client.send();
|
||||
ol.asserts.assert(false, 51); // Either `url` or `tileJSON` options must be provided
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user