Merge pull request #5652 from ahocevar/xhr-file

Make XHR work for file:// urls
This commit is contained in:
Andreas Hocevar
2016-07-28 14:52:23 +02:00
committed by GitHub
4 changed files with 10 additions and 5 deletions

View File

@@ -41,7 +41,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
* @private
*/
xhr.onload = function(event) {
if (xhr.status >= 200 && xhr.status < 300) {
// status will be 0 for file:// urls
if (!xhr.status || xhr.status >= 200 && xhr.status < 300) {
var type = format.getType();
/** @type {Document|Node|Object|string|undefined} */
var source;

View File

@@ -125,7 +125,8 @@ ol.source.CartoDB.prototype.initializeMap_ = function() {
*/
ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
if (client.status >= 200 && client.status < 300) {
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
try {
response = /** @type {CartoDBLayerInfo} */(JSON.parse(client.responseText));

View File

@@ -67,7 +67,8 @@ ol.inherits(ol.source.TileJSON, ol.source.TileImage);
*/
ol.source.TileJSON.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
if (client.status >= 200 && client.status < 300) {
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
try {
response = /** @type {TileJSON} */(JSON.parse(client.responseText));

View File

@@ -81,7 +81,8 @@ ol.inherits(ol.source.TileUTFGrid, ol.source.Tile);
*/
ol.source.TileUTFGrid.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
if (client.status >= 200 && client.status < 300) {
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
try {
response = /** @type {TileJSON} */(JSON.parse(client.responseText));
@@ -457,7 +458,8 @@ ol.source.TileUTFGridTile_.prototype.loadInternal_ = function() {
*/
ol.source.TileUTFGridTile_.prototype.onXHRLoad_ = function(event) {
var client = /** @type {XMLHttpRequest} */ (event.target);
if (client.status >= 200 && client.status < 300) {
// status will be 0 for file:// urls
if (!client.status || client.status >= 200 && client.status < 300) {
var response;
try {
response = /** @type {!UTFGridJSON} */(JSON.parse(client.responseText));