Skip to content

Instantly share code, notes, and snippets.

@jieter
Created March 23, 2016 08:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jieter/6455d153800603e74d2c to your computer and use it in GitHub Desktop.
Save jieter/6455d153800603e74d2c to your computer and use it in GitHub Desktop.
describe.only('maxBounds defined on map', function () {
chai.should();
var a, b;
afterEach(function () {
a.remove();
b.remove();
});
it('should not exceed call stack', function (done) {
// Original error:
// Uncaught RangeError: Maximum call stack size exceeded
// Github issue: https://github.com/turban/Leaflet.Sync/issues/21
var center = [60, 6];
var zoom = 5;
var bounds = L.latLngBounds([[50, 0], [60, 10]]);
a = L.map(disposableDiv(), {maxBounds: bounds}).setView(center, zoom);
b = L.map(disposableDiv(), {maxBounds: bounds});
if (!L.Browser.phantomjs) {
// do not show the tile layers in phantomjs to reduce the tile
// requests from CI
tileLayer().addTo(a);
tileLayer('toner').addTo(b);
}
a.sync(b);
b.sync(a);
// Visualize the bounds
L.rectangle(bounds).addTo(a);
// move with a hand
var h = new Hand();
var finger = h.growFinger('touch');
finger.wait(10).moveTo(200, 200, 0)
.down().moveBy(200, 0, 1000).up()
.down().moveBy(-200, 0, 1000).up();
map.on('moveend', function () {
done();
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment