Bandwidth Detection

This control adapts maps to low-bandwidth conditions. By default, it requests a test tile to determine speed, but accepts options that allow you to subsitute your own detection method. This method only works on composited tiles – that is, combinations of tilesets with the characteristic , between their tileset names.

Example

<div id='map-div'></div>
<a href='#' id='trigger-low'>low quality</a>
<a href='#' id='trigger-high'>high quality</a>
<script>
var mm = com.modestmaps;
var tilejson = {
  tilejson: '1.0.0',
  scheme: 'tms',
  tiles: ['http://a.tiles.mapbox.com/mapbox/1.0.0/blue-marble-topo-jul' +
    ',world-bank-borders-ar/{z}/{x}/{y}.png']
};

var m = new mm.Map('map-div',
  new wax.mm.connector(tilejson), null,
  [new mm.MouseHandler(), new mm.TouchHandler()]);
var bw = wax.mm.bwdetect(m, {
  png: '.png32'
});
document.getElementById('trigger-low').onclick = function() {
  bw.bw(0); return false;
};
document.getElementById('trigger-high').onclick = function() {
  bw.bw(1); return false;
};
m.setCenterZoom(new mm.Location(39, -98), 2);
</script>

API

bwdetect = wax.mm.bwdetect(map, options
Creates a new bandwidth detection object. Takes an options argument with the options:
auto
default true, if false the control will not test bandwidth
jpg
the low-quality version of JPEG files. Default `.jpg70`.
png
the low-quality version of PNG files. Default `.png128`.
bwdetect.bw(0 or 1)
Manually set the bandwidth level: 1 is for high-bandwidth / original quality, 0 is for low-bandwidth / degraded quality.
blog comments powered by Disqus