Using communistjs to load ≈100k points into a leafletjs map via transferable objects.
xxxxxxxxxx
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=1024, user-scalable=no">
<link rel="stylesheet" href="style.css" />
<link rel="stylesheet" href="https://cdn.leafletjs.com/leaflet-0.5.1/leaflet.css" />
<link rel="stylesheet" href="https://raw.github.com/Leaflet/Leaflet.markercluster/master/dist/MarkerCluster.css" />
<link rel="stylesheet" href="//raw.github.com/Leaflet/Leaflet.markercluster/master/dist/MarkerCluster.Default.css" />
<title>Leaflet Worker</title>
<div id="map"></div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/leaflet/0.5.1/leaflet.min.js"></script>
<script src="//cdn.jsdelivr.net/gh/tildeio/rsvp.js/browser/rsvp.js"></script>
<script src="//cdn.jsdelivr.net/gh/calvinmetcalf/communist/communist.js"></script>
<script src="//cdn.jsdelivr.net/gh/leaflet-extras/leaflet-providers/leaflet-providers.js"></script>
<script src="//cdn.jsdelivr.net/gh/leaflet/leaflet.markercluster/dist/leaflet.markercluster.js"></script>
<script>
var float,floatLayer;
var m = L.map("map").setView([42.391737603908844, -71.10111236572266],12);
var lc = L.control.layers.provided(["OpenStreetMap","OpenStreetMap.DE","MapQuestOpen.OSM"],{},{collapsed:false}).addTo(m);
communist.ajax("../d3/somer.json",function(a,cb){
var len = a.length;
var i = 0;
var out = new Float64Array(len*2);
while(i<len){
out[(i*2)]=a[i][0];
out[(i*2)+1]=a[i][1];
i++;
}
cb(out.buffer,[out.buffer]);
}).then(function(a){
float=new Float64Array(a);
var i = 0;
var len = float.length;
var temp = new Array(len/2);
while(i<len){
temp[i/2]=L.marker([float[i],float[i+1]]);
i++;
i++;
}
floatLayer = new L.MarkerClusterGroup();
floatLayer.addLayers(temp).addTo(m);
lc.addOverlay(floatLayer,"Float64");
});
</script>
Modified http://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js to a secure url
Updated missing url //raw.github.com/tildeio/rsvp.js/master/browser/rsvp.js to //cdn.jsdelivr.net/gh/tildeio/rsvp.js/browser/rsvp.js
Updated missing url //raw.github.com/calvinmetcalf/communist/master/communist.js to //cdn.jsdelivr.net/gh/calvinmetcalf/communist/communist.js
Updated missing url //raw.github.com/leaflet-extras/leaflet-providers/master/leaflet-providers.js to //cdn.jsdelivr.net/gh/leaflet-extras/leaflet-providers/leaflet-providers.js
Updated missing url //raw.github.com/Leaflet/Leaflet.markercluster/master/dist/leaflet.markercluster.js to //cdn.jsdelivr.net/gh/leaflet/leaflet.markercluster/dist/leaflet.markercluster.js
https://cdn.leafletjs.com/leaflet-0.5.1/leaflet.js
https://raw.github.com/tildeio/rsvp.js/master/browser/rsvp.js
https://raw.github.com/calvinmetcalf/communist/master/communist.js
https://raw.github.com/leaflet-extras/leaflet-providers/master/leaflet-providers.js
https://raw.github.com/Leaflet/Leaflet.markercluster/master/dist/leaflet.markercluster.js