commit fc9d9a65a8eb00444d542c19d75f0d314a3e17fd
parent 4b891123a6286d793fef2634cf1caea4a422deaf
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Mon, 6 Mar 2017 22:37:28 +0300
[westra passes] made compatible with IE11
IE11 doesnot support XHR.responseType='json'. Parse response with JSON.parse
Diffstat:
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/lib/leaflet.layer.geojson-ajax/index.js b/src/lib/leaflet.layer.geojson-ajax/index.js
@@ -13,14 +13,18 @@ L.Layer.GeoJSONAjax = L.GeoJSON.extend({
this.url = url;
},
+
+ // Promise can be rejected if json invalid or addData fails
loadData: function() {
if (this._loadStarted) {
return;
}
this._loadStarted = true;
- fetch(this.url, {responseType: 'json', timeout: this.options.requestTimeout})
+ fetch(this.url, {timeout: this.options.requestTimeout})
.then(
- (xhr) => this.addData(xhr.response),
+ (xhr) => {
+ this.addData(JSON.parse(xhr.response));
+ },
(e) => {
logging.captureException(e, {extra: {
description: 'failed to get geojson',
diff --git a/src/lib/leaflet.layer.westraPasses/westraPassesMarkers.js b/src/lib/leaflet.layer.westraPasses/westraPassesMarkers.js
@@ -26,7 +26,7 @@ const WestraPassesMarkers = L.Layer.CanvasMarkers.extend({
return;
}
this._downloadStarted = true;
- fetch(this.url, {responseType: 'json'})
+ fetch(this.url)
.then(
(xhr) => this._loadMarkers(xhr),
(e) => {
@@ -118,7 +118,7 @@ const WestraPassesMarkers = L.Layer.CanvasMarkers.extend({
_loadMarkers: function(xhr) {
var markers = [],
- features = xhr.response,
+ features = JSON.parse(xhr.response),
feature, i, marker;
for (i = 0; i < features.length; i++) {
feature = features[i];