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 url = 'https://api.tiles.mapbox.com/v3/mapbox.blue-marble-topo-jul.jsonp';

wax.tilejson(url, function(tilejson) {
    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({ lat: 39, lon: -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.