throw an error if ol.map gets passed an unknown option
This commit is contained in:
@@ -5,6 +5,7 @@ goog.require('ol.Map');
|
|||||||
goog.require('ol.Projection');
|
goog.require('ol.Projection');
|
||||||
goog.require('ol.loc');
|
goog.require('ol.loc');
|
||||||
goog.require('ol.projection');
|
goog.require('ol.projection');
|
||||||
|
goog.require('ol.error');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,21 +50,38 @@ ol.map = function(opt_arg) {
|
|||||||
}
|
}
|
||||||
else if (goog.isObject(opt_arg)) {
|
else if (goog.isObject(opt_arg)) {
|
||||||
center = opt_arg['center'];
|
center = opt_arg['center'];
|
||||||
|
delete opt_arg['center'];
|
||||||
zoom = opt_arg['zoom'];
|
zoom = opt_arg['zoom'];
|
||||||
|
delete opt_arg['zoom'];
|
||||||
numZoomLevels = opt_arg['numZoomLevels'];
|
numZoomLevels = opt_arg['numZoomLevels'];
|
||||||
|
delete opt_arg['numZoomLevels'];
|
||||||
projection = opt_arg['projection'];
|
projection = opt_arg['projection'];
|
||||||
|
delete opt_arg['projection'];
|
||||||
userProjection = opt_arg['userProjection'];
|
userProjection = opt_arg['userProjection'];
|
||||||
|
delete opt_arg['userProjection'];
|
||||||
maxExtent = opt_arg['maxExtent'];
|
maxExtent = opt_arg['maxExtent'];
|
||||||
|
delete opt_arg['maxExtent'];
|
||||||
maxRes = opt_arg['maxRes'];
|
maxRes = opt_arg['maxRes'];
|
||||||
|
delete opt_arg['maxRes'];
|
||||||
resolutions = opt_arg['resolutions'];
|
resolutions = opt_arg['resolutions'];
|
||||||
|
delete opt_arg['resolutions'];
|
||||||
el = opt_arg['el'];
|
el = opt_arg['el'];
|
||||||
|
delete opt_arg['el'];
|
||||||
layers = opt_arg['layers'];
|
layers = opt_arg['layers'];
|
||||||
|
delete opt_arg['layers'];
|
||||||
controls = opt_arg['controls'];
|
controls = opt_arg['controls'];
|
||||||
|
delete opt_arg['controls'];
|
||||||
|
var k = goog.object.getAnyKey(opt_arg);
|
||||||
|
if (goog.isDef(k)) {
|
||||||
|
ol.error(k + ' is not a map option');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error('ol.map');
|
throw new Error('ol.map');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var map = new ol.Map();
|
var map = new ol.Map();
|
||||||
if (goog.isDef(el)) {
|
if (goog.isDef(el)) {
|
||||||
|
|||||||
@@ -144,21 +144,11 @@ describe("ol.map", function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("provides feedback when you mess up", function() {
|
it("provides feedback when you mess up", function() {
|
||||||
var map;
|
expect(function() {
|
||||||
if (goog.DEBUG) {
|
var map = ol.map({
|
||||||
// misspelling
|
centre: [1, 2]
|
||||||
expect(function() {
|
});
|
||||||
map = ol.map({
|
}).toThrow();
|
||||||
centre: [1, 2]
|
|
||||||
});
|
|
||||||
}).toThrow(new Error("Unsupported config property: centre"));
|
|
||||||
} else {
|
|
||||||
expect(function() {
|
|
||||||
map = ol.map({
|
|
||||||
centre: [1, 2]
|
|
||||||
});
|
|
||||||
}).not.toThrow();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("is destroyable", function() {
|
it("is destroyable", function() {
|
||||||
|
|||||||
Reference in New Issue
Block a user