Make XHR work for file:// urls
The response status will be 0 instead of a HTTP status code for file urls, so we need to consider a status of 0 as success too.
This commit is contained in:
@@ -41,7 +41,8 @@ ol.featureloader.loadFeaturesXhr = function(url, format, success, failure) {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
xhr.onload = function(event) {
|
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();
|
var type = format.getType();
|
||||||
/** @type {Document|Node|Object|string|undefined} */
|
/** @type {Document|Node|Object|string|undefined} */
|
||||||
var source;
|
var source;
|
||||||
|
|||||||
@@ -125,7 +125,8 @@ ol.source.CartoDB.prototype.initializeMap_ = function() {
|
|||||||
*/
|
*/
|
||||||
ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
|
ol.source.CartoDB.prototype.handleInitResponse_ = function(paramHash, event) {
|
||||||
var client = /** @type {XMLHttpRequest} */ (event.target);
|
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;
|
var response;
|
||||||
try {
|
try {
|
||||||
response = /** @type {CartoDBLayerInfo} */(JSON.parse(client.responseText));
|
response = /** @type {CartoDBLayerInfo} */(JSON.parse(client.responseText));
|
||||||
|
|||||||
@@ -67,7 +67,8 @@ ol.inherits(ol.source.TileJSON, ol.source.TileImage);
|
|||||||
*/
|
*/
|
||||||
ol.source.TileJSON.prototype.onXHRLoad_ = function(event) {
|
ol.source.TileJSON.prototype.onXHRLoad_ = function(event) {
|
||||||
var client = /** @type {XMLHttpRequest} */ (event.target);
|
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;
|
var response;
|
||||||
try {
|
try {
|
||||||
response = /** @type {TileJSON} */(JSON.parse(client.responseText));
|
response = /** @type {TileJSON} */(JSON.parse(client.responseText));
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ ol.inherits(ol.source.TileUTFGrid, ol.source.Tile);
|
|||||||
*/
|
*/
|
||||||
ol.source.TileUTFGrid.prototype.onXHRLoad_ = function(event) {
|
ol.source.TileUTFGrid.prototype.onXHRLoad_ = function(event) {
|
||||||
var client = /** @type {XMLHttpRequest} */ (event.target);
|
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;
|
var response;
|
||||||
try {
|
try {
|
||||||
response = /** @type {TileJSON} */(JSON.parse(client.responseText));
|
response = /** @type {TileJSON} */(JSON.parse(client.responseText));
|
||||||
@@ -457,7 +458,8 @@ ol.source.TileUTFGridTile_.prototype.loadInternal_ = function() {
|
|||||||
*/
|
*/
|
||||||
ol.source.TileUTFGridTile_.prototype.onXHRLoad_ = function(event) {
|
ol.source.TileUTFGridTile_.prototype.onXHRLoad_ = function(event) {
|
||||||
var client = /** @type {XMLHttpRequest} */ (event.target);
|
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;
|
var response;
|
||||||
try {
|
try {
|
||||||
response = /** @type {!UTFGridJSON} */(JSON.parse(client.responseText));
|
response = /** @type {!UTFGridJSON} */(JSON.parse(client.responseText));
|
||||||
|
|||||||
Reference in New Issue
Block a user