mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-27 08:02:51 +02:00
Throw an error if a MarkerClusterGroup is added to a map with no maxZoom. Fixes #189
This commit is contained in:
@@ -40,6 +40,7 @@
|
||||
<script type="text/javascript" src="suites/CircleMarkerSupportSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/CircleSupportSpec.js"></script>
|
||||
|
||||
<script type="text/javascript" src="suites/onAddSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/clearLayersSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/eachLayerSpec.js"></script>
|
||||
<script type="text/javascript" src="suites/eventsSpec.js"></script>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
describe('onAdd', function () {
|
||||
var map, div;
|
||||
beforeEach(function () {
|
||||
div = document.createElement('div');
|
||||
div.style.width = '200px';
|
||||
div.style.height = '200px';
|
||||
document.body.appendChild(div);
|
||||
|
||||
map = L.map(div);
|
||||
|
||||
map.fitBounds(new L.LatLngBounds([
|
||||
[1, 1],
|
||||
[2, 2]
|
||||
]));
|
||||
});
|
||||
afterEach(function () {
|
||||
document.body.removeChild(div);
|
||||
});
|
||||
|
||||
|
||||
it('throws an error if maxZoom is not specified', function () {
|
||||
|
||||
var group = new L.MarkerClusterGroup();
|
||||
var marker = new L.Marker([1.5, 1.5]);
|
||||
|
||||
group.addLayer(marker);
|
||||
|
||||
var ex = null;
|
||||
try {
|
||||
map.addLayer(group);
|
||||
} catch (e) {
|
||||
ex = e;
|
||||
}
|
||||
|
||||
expect(ex).to.not.be(null);
|
||||
});
|
||||
});
|
||||
@@ -370,6 +370,10 @@ L.MarkerClusterGroup = L.FeatureGroup.extend({
|
||||
this._map = map;
|
||||
var i, l, layer;
|
||||
|
||||
if (!isFinite(this._map.getMaxZoom())) {
|
||||
throw "Map has no maxZoom specified";
|
||||
}
|
||||
|
||||
this._featureGroup.onAdd(map);
|
||||
this._nonPointGroup.onAdd(map);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user