diff --git a/examples/basic/main.js b/examples/basic/main.js
index c905bd6..f5e4e35 100644
--- a/examples/basic/main.js
+++ b/examples/basic/main.js
@@ -12,9 +12,9 @@ VIZI.Controls.orbit().addTo(world);
// CartoDB basemap
VIZI.imageTileLayer('http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors, © CartoDB'
-}).addTo(world).then(() => {
+}).addTo(world).then(function() {
console.log('Added image tile layer to world');
-});;
+});
// Buildings from Mapzen
VIZI.topoJSONTileLayer('https://tile.mapzen.com/mapzen/vector/v1/buildings/{z}/{x}/{y}.topojson?api_key=vector-tiles-NT5Emiw', {
@@ -37,6 +37,6 @@ VIZI.topoJSONTileLayer('https://tile.mapzen.com/mapzen/vector/v1/buildings/{z}/{
return feature.geometry.type !== 'Point';
},
attribution: '© OpenStreetMap contributors, Who\'s On First.'
-}).addTo(world).then(() => {
+}).addTo(world).then(function() {
console.log('Added TopoJSON layer to world');
});
diff --git a/examples/tile-events/main.js b/examples/tile-events/main.js
index bff7594..e9f1fa8 100644
--- a/examples/tile-events/main.js
+++ b/examples/tile-events/main.js
@@ -14,12 +14,12 @@ var imageTiles = VIZI.imageTileLayer('http://{s}.basemaps.cartocdn.com/light_nol
attribution: '© OpenStreetMap contributors, © CartoDB'
});
-imageTiles.addTo(world).then(() => {
+imageTiles.addTo(world).then(function() {
console.log('Added image tile layer to world');
});
// Will be emitted every time the image layer updates the tile list
// All tiles in view are sent with each update
-imageTiles.on('tilesList', (tiles) => {
+imageTiles.on('tilesList', function(tiles) {
console.log(tiles);
});
\ No newline at end of file
diff --git a/examples/web-workers-all-the-things/main.js b/examples/web-workers-all-the-things/main.js
index 75d8717..19697ca 100644
--- a/examples/web-workers-all-the-things/main.js
+++ b/examples/web-workers-all-the-things/main.js
@@ -13,7 +13,7 @@ world._environment._skybox.setInclination(0.3);
VIZI.Controls.orbit().addTo(world);
// Leave a single CPU for the main browser thread
-world.createWorkers(7).then(() => {
+world.createWorkers(7).then(function() {
console.log('Workers ready');
// CartoDB basemap
diff --git a/examples/web-workers-all-the-things/vizicities-worker.js b/examples/web-workers-all-the-things/vizicities-worker.js
index 5bc48fa..87b80f7 100644
--- a/examples/web-workers-all-the-things/vizicities-worker.js
+++ b/examples/web-workers-all-the-things/vizicities-worker.js
@@ -14,7 +14,7 @@ postMessage({
});
// Recieve message from main thread
-onmessage = (event) => {
+onmessage = function(event) {
if (!event.data.method) {
postMessage({
type: 'error',
@@ -49,7 +49,7 @@ onmessage = (event) => {
}
// Call method with given arguments
- _method.apply(this, event.data.args).then((result) => {
+ _method.apply(this, event.data.args).then(function(result) {
if (DEBUG) { console.log('Message sent from worker', Date.now()); }
// Return results
diff --git a/examples/web-workers-basic/main.js b/examples/web-workers-basic/main.js
index 0d4872d..2ec96d3 100644
--- a/examples/web-workers-basic/main.js
+++ b/examples/web-workers-basic/main.js
@@ -10,13 +10,13 @@ var world = VIZI.world('world', {
VIZI.Controls.orbit().addTo(world);
// Leave a single CPU for the main browser thread
-world.createWorkers(7).then(() => {
+world.createWorkers(7).then(function() {
console.log('Workers ready');
// CartoDB basemap
VIZI.imageTileLayer('http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors, © CartoDB'
- }).addTo(world).then(() => {
+ }).addTo(world).then(function() {
console.log('Added image tile layer to world');
});;
@@ -42,7 +42,7 @@ world.createWorkers(7).then(() => {
return feature.geometry.type !== 'Point';
},
attribution: '© OpenStreetMap contributors, Who\'s On First.'
- }).addTo(world).then(() => {
+ }).addTo(world).then(function() {
console.log('Added TopoJSON layer to world');
});
});
diff --git a/examples/web-workers-basic/vizicities-worker.js b/examples/web-workers-basic/vizicities-worker.js
index 5bc48fa..87b80f7 100644
--- a/examples/web-workers-basic/vizicities-worker.js
+++ b/examples/web-workers-basic/vizicities-worker.js
@@ -14,7 +14,7 @@ postMessage({
});
// Recieve message from main thread
-onmessage = (event) => {
+onmessage = function(event) {
if (!event.data.method) {
postMessage({
type: 'error',
@@ -49,7 +49,7 @@ onmessage = (event) => {
}
// Call method with given arguments
- _method.apply(this, event.data.args).then((result) => {
+ _method.apply(this, event.data.args).then(function(result) {
if (DEBUG) { console.log('Message sent from worker', Date.now()); }
// Return results
diff --git a/examples/web-workers-geojson/main.js b/examples/web-workers-geojson/main.js
index 73b5d6c..321cbe6 100644
--- a/examples/web-workers-geojson/main.js
+++ b/examples/web-workers-geojson/main.js
@@ -10,7 +10,7 @@ var world = VIZI.world('world', {
VIZI.Controls.orbit().addTo(world);
// Leave a single CPU for the main browser thread
-world.createWorkers(7).then(() => {
+world.createWorkers(7).then(function() {
console.log('Workers ready');
// CartoDB basemap
diff --git a/examples/web-workers-geojson/vizicities-worker.js b/examples/web-workers-geojson/vizicities-worker.js
index 5bc48fa..87b80f7 100644
--- a/examples/web-workers-geojson/vizicities-worker.js
+++ b/examples/web-workers-geojson/vizicities-worker.js
@@ -14,7 +14,7 @@ postMessage({
});
// Recieve message from main thread
-onmessage = (event) => {
+onmessage = function(event) {
if (!event.data.method) {
postMessage({
type: 'error',
@@ -49,7 +49,7 @@ onmessage = (event) => {
}
// Call method with given arguments
- _method.apply(this, event.data.args).then((result) => {
+ _method.apply(this, event.data.args).then(function(result) {
if (DEBUG) { console.log('Message sent from worker', Date.now()); }
// Return results
diff --git a/examples/web-workers-outlines/main.js b/examples/web-workers-outlines/main.js
index a902366..70ebbf7 100644
--- a/examples/web-workers-outlines/main.js
+++ b/examples/web-workers-outlines/main.js
@@ -10,13 +10,13 @@ var world = VIZI.world('world', {
VIZI.Controls.orbit().addTo(world);
// Leave a single CPU for the main browser thread
-world.createWorkers(7).then(() => {
+world.createWorkers(7).then(function() {
console.log('Workers ready');
// CartoDB basemap
VIZI.imageTileLayer('http://{s}.basemaps.cartocdn.com/light_nolabels/{z}/{x}/{y}.png', {
attribution: '© OpenStreetMap contributors, © CartoDB'
- }).addTo(world).then(() => {
+ }).addTo(world).then(function() {
console.log('Added image tile layer to world');
});
@@ -43,7 +43,7 @@ world.createWorkers(7).then(() => {
return feature.geometry.type !== 'Point';
},
attribution: '© OpenStreetMap contributors, Who\'s On First.'
- }).addTo(world).then(() => {
+ }).addTo(world).then(function() {
console.log('Added TopoJSON layer to world');
});
});
diff --git a/examples/web-workers-outlines/vizicities-worker.js b/examples/web-workers-outlines/vizicities-worker.js
index 5bc48fa..87b80f7 100644
--- a/examples/web-workers-outlines/vizicities-worker.js
+++ b/examples/web-workers-outlines/vizicities-worker.js
@@ -14,7 +14,7 @@ postMessage({
});
// Recieve message from main thread
-onmessage = (event) => {
+onmessage = function(event) {
if (!event.data.method) {
postMessage({
type: 'error',
@@ -49,7 +49,7 @@ onmessage = (event) => {
}
// Call method with given arguments
- _method.apply(this, event.data.args).then((result) => {
+ _method.apply(this, event.data.args).then(function(result) {
if (DEBUG) { console.log('Message sent from worker', Date.now()); }
// Return results
diff --git a/gulpfile.babel.js b/gulpfile.babel.js
index cd0351e..e1d1d21 100644
--- a/gulpfile.babel.js
+++ b/gulpfile.babel.js
@@ -92,6 +92,11 @@ function build() {
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' }
]
},
+ plugins: [
+ new webpack.ProvidePlugin({
+ Promise: 'promise-polyfill'
+ })
+ ],
devtool: 'source-map'
}))
.pipe(gulp.dest(destinationFolder))
@@ -138,6 +143,11 @@ function buildWorker() {
{ test: /\.js$/, exclude: /node_modules/, loader: 'babel-loader' },
]
},
+ plugins: [
+ new webpack.ProvidePlugin({
+ Promise: 'promise-polyfill'
+ })
+ ],
devtool: 'source-map'
}))
.pipe(gulp.dest(destinationFolder))
diff --git a/package.json b/package.json
index 81c3611..25c5c01 100644
--- a/package.json
+++ b/package.json
@@ -87,6 +87,7 @@
"lodash.assign": "^4.0.2",
"lodash.throttle": "^4.0.0",
"lru-cache": "^4.0.0",
+ "promise-polyfill": "^6.0.2",
"reqwest": "^2.0.5",
"shortid": "^2.2.6",
"text-encoding": "^0.6.1",
diff --git a/src/layer/GeoJSONWorkerLayer.js b/src/layer/GeoJSONWorkerLayer.js
index 3a51ce6..bc99a75 100644
--- a/src/layer/GeoJSONWorkerLayer.js
+++ b/src/layer/GeoJSONWorkerLayer.js
@@ -225,7 +225,7 @@ class GeoJSONWorkerLayer extends Layer {
pickingId = this.getPickingId();
pickingIds = new Float32Array(splitPositions[i].length / 3);
- pickingIds.fill(pickingId);
+ Buffer.fillTypedArray(pickingIds, pickingId);
obj.attributes[0].pickingIds = pickingIds;
@@ -387,7 +387,7 @@ class GeoJSONWorkerLayer extends Layer {
pickingId = this.getPickingId();
pickingIds = new Float32Array(splitPositions[i].length / 3);
- pickingIds.fill(pickingId);
+ Buffer.fillTypedArray(pickingIds, pickingId);
obj.attributes[0].pickingIds = pickingIds;
@@ -498,7 +498,7 @@ class GeoJSONWorkerLayer extends Layer {
pickingId = this.getPickingId();
pickingIds = new Float32Array(splitPositions[i].length / 3);
- pickingIds.fill(pickingId);
+ Buffer.fillTypedArray(pickingIds, pickingId);
obj.attributes[0].pickingIds = pickingIds;
diff --git a/src/layer/tile/TileLayer.js b/src/layer/tile/TileLayer.js
index ca2cbaf..9a6156e 100644
--- a/src/layer/tile/TileLayer.js
+++ b/src/layer/tile/TileLayer.js
@@ -212,7 +212,7 @@ class TileLayer extends Layer {
// Get list of tiles that were in the previous update but not the
// current one (for aborting requests, etc)
var missingTiles = this._tileList.filter((item) => {
- return !tileList.includes(item);
+ return tileList.indexOf(item) < 0;
});
// Abort tiles that are no longer in view
diff --git a/src/util/Buffer.js b/src/util/Buffer.js
index 4aaa8e1..6042a38 100644
--- a/src/util/Buffer.js
+++ b/src/util/Buffer.js
@@ -353,6 +353,12 @@ var Buffer = (function() {
return textDecoder.decode(ab);
};
+ var fillTypedArray = function(arr, value) {
+ for (var i = 0; i < arr.length; i++) {
+ arr[i] = value;
+ }
+ };
+
return {
mergeFloat32Arrays: mergeFloat32Arrays,
splitFloat32Array: splitFloat32Array,
@@ -362,7 +368,8 @@ var Buffer = (function() {
createLineGeometry: createLineGeometry,
createGeometry: createGeometry,
stringToUint8Array: stringToUint8Array,
- uint8ArrayToString: uint8ArrayToString
+ uint8ArrayToString: uint8ArrayToString,
+ fillTypedArray: fillTypedArray
};
})();
diff --git a/src/util/WorkerPool.js b/src/util/WorkerPool.js
index e9a2afb..0b5d496 100644
--- a/src/util/WorkerPool.js
+++ b/src/util/WorkerPool.js
@@ -2,6 +2,33 @@ import WorkerPoolWorker from './WorkerPoolWorker';
const DEBUG = false;
+// Polyfill for Array.find
+if (!Array.prototype.find) {
+ Object.defineProperty(Array.prototype, 'find', {
+ value: function(predicate) {
+ 'use strict';
+ if (this == null) {
+ throw new TypeError('Array.prototype.find called on null or undefined');
+ }
+ if (typeof predicate !== 'function') {
+ throw new TypeError('predicate must be a function');
+ }
+ var list = Object(this);
+ var length = list.length >>> 0;
+ var thisArg = arguments[1];
+ var value;
+
+ for (var i = 0; i < length; i++) {
+ value = list[i];
+ if (predicate.call(thisArg, value, i, list)) {
+ return value;
+ }
+ }
+ return undefined;
+ }
+ });
+}
+
class WorkerPool {
constructor(options) {
this.numThreads = options.numThreads || 2;