Inline goog.isDef() property checks

This commit is contained in:
Tim Schaub
2015-09-27 10:21:50 -06:00
parent 7659e47e07
commit b36d697585
27 changed files with 58 additions and 58 deletions

View File

@@ -90,10 +90,10 @@ ol.Geolocation = function(opt_options) {
this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING), this, ol.Object.getChangeEventType(ol.GeolocationProperty.TRACKING),
this.handleTrackingChanged_, false, this); this.handleTrackingChanged_, false, this);
if (goog.isDef(options.projection)) { if (options.projection !== undefined) {
this.setProjection(ol.proj.get(options.projection)); this.setProjection(ol.proj.get(options.projection));
} }
if (goog.isDef(options.trackingOptions)) { if (options.trackingOptions !== undefined) {
this.setTrackingOptions(options.trackingOptions); this.setTrackingOptions(options.trackingOptions);
} }

View File

@@ -44,7 +44,7 @@ ol.has.CANVAS = ol.ENABLE_CANVAS && (
if (goog.isNull(context)) { if (goog.isNull(context)) {
return false; return false;
} else { } else {
if (goog.isDef(context.setLineDash)) { if (context.setLineDash !== undefined) {
ol.has.CANVAS_LINE_DASH = true; ol.has.CANVAS_LINE_DASH = true;
} }
return true; return true;

View File

@@ -226,8 +226,8 @@ ol.layer.Group.prototype.getLayerStatesArray = function(opt_states) {
layerState.maxResolution, ownLayerState.maxResolution); layerState.maxResolution, ownLayerState.maxResolution);
layerState.minResolution = Math.max( layerState.minResolution = Math.max(
layerState.minResolution, ownLayerState.minResolution); layerState.minResolution, ownLayerState.minResolution);
if (goog.isDef(ownLayerState.extent)) { if (ownLayerState.extent !== undefined) {
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
layerState.extent = ol.extent.getIntersection( layerState.extent = ol.extent.getIntersection(
layerState.extent, ownLayerState.extent); layerState.extent, ownLayerState.extent);
} else { } else {

View File

@@ -1452,7 +1452,7 @@ ol.Map.createOptionsInternal = function(options) {
* @type {Element|Document} * @type {Element|Document}
*/ */
var keyboardEventTarget = null; var keyboardEventTarget = null;
if (goog.isDef(options.keyboardEventTarget)) { if (options.keyboardEventTarget !== undefined) {
// cannot use goog.dom.getElement because its argument cannot be // cannot use goog.dom.getElement because its argument cannot be
// of type Document // of type Document
keyboardEventTarget = goog.isString(options.keyboardEventTarget) ? keyboardEventTarget = goog.isString(options.keyboardEventTarget) ?
@@ -1498,7 +1498,7 @@ ol.Map.createOptionsInternal = function(options) {
* @type {Array.<ol.RendererType>} * @type {Array.<ol.RendererType>}
*/ */
var rendererTypes; var rendererTypes;
if (goog.isDef(options.renderer)) { if (options.renderer !== undefined) {
if (goog.isArray(options.renderer)) { if (goog.isArray(options.renderer)) {
rendererTypes = options.renderer; rendererTypes = options.renderer;
} else if (goog.isString(options.renderer)) { } else if (goog.isString(options.renderer)) {
@@ -1533,7 +1533,7 @@ ol.Map.createOptionsInternal = function(options) {
} }
var controls; var controls;
if (goog.isDef(options.controls)) { if (options.controls !== undefined) {
if (goog.isArray(options.controls)) { if (goog.isArray(options.controls)) {
controls = new ol.Collection(options.controls.slice()); controls = new ol.Collection(options.controls.slice());
} else { } else {
@@ -1546,7 +1546,7 @@ ol.Map.createOptionsInternal = function(options) {
} }
var interactions; var interactions;
if (goog.isDef(options.interactions)) { if (options.interactions !== undefined) {
if (goog.isArray(options.interactions)) { if (goog.isArray(options.interactions)) {
interactions = new ol.Collection(options.interactions.slice()); interactions = new ol.Collection(options.interactions.slice());
} else { } else {
@@ -1559,7 +1559,7 @@ ol.Map.createOptionsInternal = function(options) {
} }
var overlays; var overlays;
if (goog.isDef(options.overlays)) { if (options.overlays !== undefined) {
if (goog.isArray(options.overlays)) { if (goog.isArray(options.overlays)) {
overlays = new ol.Collection(options.overlays.slice()); overlays = new ol.Collection(options.overlays.slice());
} else { } else {

View File

@@ -158,7 +158,7 @@ ol.Overlay = function(options) {
this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITIONING), this, ol.Object.getChangeEventType(ol.OverlayProperty.POSITIONING),
this.handlePositioningChanged, false, this); this.handlePositioningChanged, false, this);
if (goog.isDef(options.element)) { if (options.element !== undefined) {
this.setElement(options.element); this.setElement(options.element);
} }
@@ -168,7 +168,7 @@ ol.Overlay = function(options) {
/** @type {ol.OverlayPositioning} */ (options.positioning) : /** @type {ol.OverlayPositioning} */ (options.positioning) :
ol.OverlayPositioning.TOP_LEFT); ol.OverlayPositioning.TOP_LEFT);
if (goog.isDef(options.position)) { if (options.position !== undefined) {
this.setPosition(options.position); this.setPosition(options.position);
} }

View File

@@ -155,7 +155,7 @@ ol.proj.Projection = function(options) {
if (!goog.isDef(options.units)) { if (!goog.isDef(options.units)) {
var units = def.units; var units = def.units;
if (!goog.isDef(units)) { if (!goog.isDef(units)) {
if (goog.isDef(def.to_meter)) { if (def.to_meter !== undefined) {
units = def.to_meter.toString(); units = def.to_meter.toString();
ol.proj.METERS_PER_UNIT[units] = def.to_meter; ol.proj.METERS_PER_UNIT[units] = def.to_meter;
} }

View File

@@ -1194,10 +1194,10 @@ ol.render.canvas.PolygonReplay.prototype.drawFlatCoordinatess_ =
// FIXME or all polygons together? // FIXME or all polygons together?
var fillInstruction = [ol.render.canvas.Instruction.FILL]; var fillInstruction = [ol.render.canvas.Instruction.FILL];
this.hitDetectionInstructions.push(fillInstruction); this.hitDetectionInstructions.push(fillInstruction);
if (goog.isDef(state.fillStyle)) { if (state.fillStyle !== undefined) {
this.instructions.push(fillInstruction); this.instructions.push(fillInstruction);
} }
if (goog.isDef(state.strokeStyle)) { if (state.strokeStyle !== undefined) {
goog.asserts.assert(goog.isDef(state.lineWidth), goog.asserts.assert(goog.isDef(state.lineWidth),
'state.lineWidth should be defined'); 'state.lineWidth should be defined');
var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
@@ -1230,7 +1230,7 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry =
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_FILL_STYLE, [ol.render.canvas.Instruction.SET_FILL_STYLE,
ol.color.asString(ol.render.canvas.defaultFillStyle)]); ol.color.asString(ol.render.canvas.defaultFillStyle)]);
if (goog.isDef(state.strokeStyle)) { if (state.strokeStyle !== undefined) {
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_STROKE_STYLE, [ol.render.canvas.Instruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -1247,10 +1247,10 @@ ol.render.canvas.PolygonReplay.prototype.drawCircleGeometry =
this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction); this.hitDetectionInstructions.push(beginPathInstruction, circleInstruction);
var fillInstruction = [ol.render.canvas.Instruction.FILL]; var fillInstruction = [ol.render.canvas.Instruction.FILL];
this.hitDetectionInstructions.push(fillInstruction); this.hitDetectionInstructions.push(fillInstruction);
if (goog.isDef(state.fillStyle)) { if (state.fillStyle !== undefined) {
this.instructions.push(fillInstruction); this.instructions.push(fillInstruction);
} }
if (goog.isDef(state.strokeStyle)) { if (state.strokeStyle !== undefined) {
goog.asserts.assert(goog.isDef(state.lineWidth), goog.asserts.assert(goog.isDef(state.lineWidth),
'state.lineWidth should be defined'); 'state.lineWidth should be defined');
var strokeInstruction = [ol.render.canvas.Instruction.STROKE]; var strokeInstruction = [ol.render.canvas.Instruction.STROKE];
@@ -1283,7 +1283,7 @@ ol.render.canvas.PolygonReplay.prototype.drawPolygonGeometry =
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_FILL_STYLE, [ol.render.canvas.Instruction.SET_FILL_STYLE,
ol.color.asString(ol.render.canvas.defaultFillStyle)]); ol.color.asString(ol.render.canvas.defaultFillStyle)]);
if (goog.isDef(state.strokeStyle)) { if (state.strokeStyle !== undefined) {
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_STROKE_STYLE, [ol.render.canvas.Instruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -1319,7 +1319,7 @@ ol.render.canvas.PolygonReplay.prototype.drawMultiPolygonGeometry =
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_FILL_STYLE, [ol.render.canvas.Instruction.SET_FILL_STYLE,
ol.color.asString(ol.render.canvas.defaultFillStyle)]); ol.color.asString(ol.render.canvas.defaultFillStyle)]);
if (goog.isDef(state.strokeStyle)) { if (state.strokeStyle !== undefined) {
this.hitDetectionInstructions.push( this.hitDetectionInstructions.push(
[ol.render.canvas.Instruction.SET_STROKE_STYLE, [ol.render.canvas.Instruction.SET_STROKE_STYLE,
state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin, state.strokeStyle, state.lineWidth, state.lineCap, state.lineJoin,
@@ -1887,7 +1887,7 @@ ol.render.canvas.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
* @type {ol.Extent} * @type {ol.Extent}
*/ */
var hitExtent; var hitExtent;
if (goog.isDef(this.renderBuffer_)) { if (this.renderBuffer_ !== undefined) {
hitExtent = ol.extent.createEmpty(); hitExtent = ol.extent.createEmpty();
ol.extent.extendCoordinate(hitExtent, coordinate); ol.extent.extendCoordinate(hitExtent, coordinate);
ol.extent.buffer(hitExtent, resolution * this.renderBuffer_, hitExtent); ol.extent.buffer(hitExtent, resolution * this.renderBuffer_, hitExtent);

View File

@@ -1163,7 +1163,7 @@ ol.render.webgl.ReplayGroup.prototype.forEachFeatureAtCoordinate = function(
* @type {ol.Extent} * @type {ol.Extent}
*/ */
var hitExtent; var hitExtent;
if (goog.isDef(this.renderBuffer_)) { if (this.renderBuffer_ !== undefined) {
// build an extent around the coordinate, so that only features that // build an extent around the coordinate, so that only features that
// intersect this extent are checked // intersect this extent are checked
hitExtent = ol.extent.buffer( hitExtent = ol.extent.buffer(

View File

@@ -163,7 +163,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
var hints = frameState.viewHints; var hints = frameState.viewHints;
var renderedExtent = frameState.extent; var renderedExtent = frameState.extent;
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
renderedExtent = ol.extent.getIntersection( renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent); renderedExtent, layerState.extent);
} }

View File

@@ -217,7 +217,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
extent = frameState.extent; extent = frameState.extent;
} }
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
extent = ol.extent.getIntersection(extent, layerState.extent); extent = ol.extent.getIntersection(extent, layerState.extent);
} }
if (ol.extent.isEmpty(extent)) { if (ol.extent.isEmpty(extent)) {

View File

@@ -94,7 +94,7 @@ ol.renderer.dom.ImageLayer.prototype.prepareFrame =
var hints = frameState.viewHints; var hints = frameState.viewHints;
var renderedExtent = frameState.extent; var renderedExtent = frameState.extent;
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
renderedExtent = ol.extent.getIntersection( renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent); renderedExtent, layerState.extent);
} }

View File

@@ -119,7 +119,7 @@ ol.renderer.dom.TileLayer.prototype.prepareFrame =
extent = frameState.extent; extent = frameState.extent;
} }
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
extent = ol.extent.getIntersection(extent, layerState.extent); extent = ol.extent.getIntersection(extent, layerState.extent);
} }

View File

@@ -118,7 +118,7 @@ ol.renderer.webgl.ImageLayer.prototype.prepareFrame =
var hints = frameState.viewHints; var hints = frameState.viewHints;
var renderedExtent = frameState.extent; var renderedExtent = frameState.extent;
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
renderedExtent = ol.extent.getIntersection( renderedExtent = ol.extent.getIntersection(
renderedExtent, layerState.extent); renderedExtent, layerState.extent);
} }

View File

@@ -251,7 +251,7 @@ ol.renderer.webgl.TileLayer.prototype.prepareFrame =
for (y = tileRange.minY; y <= tileRange.maxY; ++y) { for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
tile = tileSource.getTile(z, x, y, pixelRatio, projection); tile = tileSource.getTile(z, x, y, pixelRatio, projection);
if (goog.isDef(layerState.extent)) { if (layerState.extent !== undefined) {
// ignore tiles outside layer extent // ignore tiles outside layer extent
tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent); tileExtent = tileGrid.getTileCoordExtent(tile.tileCoord, tmpExtent);
if (!ol.extent.intersects(tileExtent, layerState.extent)) { if (!ol.extent.intersects(tileExtent, layerState.extent)) {

View File

@@ -50,7 +50,7 @@ ol.source.ImageMapGuide = function(options) {
this.params_ = goog.isDef(options.params) ? options.params : {}; this.params_ = goog.isDef(options.params) ? options.params : {};
var imageUrlFunction; var imageUrlFunction;
if (goog.isDef(options.url)) { if (options.url !== undefined) {
imageUrlFunction = ol.ImageUrlFunction.createFromParamsFunction( imageUrlFunction = ol.ImageUrlFunction.createFromParamsFunction(
options.url, this.params_, goog.bind(this.getUrl, this)); options.url, this.params_, goog.bind(this.getUrl, this));
} else { } else {

View File

@@ -27,7 +27,7 @@ ol.source.ImageStatic = function(options) {
var imageExtent = options.imageExtent; var imageExtent = options.imageExtent;
var resolution, resolutions; var resolution, resolutions;
if (goog.isDef(options.imageSize)) { if (options.imageSize !== undefined) {
resolution = ol.extent.getHeight(imageExtent) / options.imageSize[1]; resolution = ol.extent.getHeight(imageExtent) / options.imageSize[1];
resolutions = [resolution]; resolutions = [resolution];
} }

View File

@@ -261,7 +261,7 @@ ol.source.ImageVector.prototype.renderFeature_ =
var styles; var styles;
if (goog.isDef(feature.getStyleFunction())) { if (goog.isDef(feature.getStyleFunction())) {
styles = feature.getStyleFunction().call(feature, resolution); styles = feature.getStyleFunction().call(feature, resolution);
} else if (goog.isDef(this.styleFunction_)) { } else if (this.styleFunction_ !== undefined) {
styles = this.styleFunction_(feature, resolution); styles = this.styleFunction_(feature, resolution);
} }
if (!goog.isDefAndNotNull(styles)) { if (!goog.isDefAndNotNull(styles)) {

View File

@@ -19,7 +19,7 @@ ol.source.OSM = function(opt_options) {
var options = opt_options || {}; var options = opt_options || {};
var attributions; var attributions;
if (goog.isDef(options.attributions)) { if (options.attributions !== undefined) {
attributions = options.attributions; attributions = options.attributions;
} else { } else {
attributions = [ol.source.OSM.ATTRIBUTION]; attributions = [ol.source.OSM.ATTRIBUTION];

View File

@@ -133,7 +133,7 @@ ol.source.Raster = function(options) {
goog.base(this, {}); goog.base(this, {});
if (goog.isDef(options.operation)) { if (options.operation !== undefined) {
this.setOperation(options.operation, options.lib); this.setOperation(options.operation, options.lib);
} }

View File

@@ -57,13 +57,13 @@ ol.source.TileJSON.prototype.handleTileJSONResponse = function(tileJSON) {
var sourceProjection = this.getProjection(); var sourceProjection = this.getProjection();
var extent; var extent;
if (goog.isDef(tileJSON.bounds)) { if (tileJSON.bounds !== undefined) {
var transform = ol.proj.getTransformFromProjections( var transform = ol.proj.getTransformFromProjections(
epsg4326Projection, sourceProjection); epsg4326Projection, sourceProjection);
extent = ol.extent.applyTransform(tileJSON.bounds, transform); extent = ol.extent.applyTransform(tileJSON.bounds, transform);
} }
if (goog.isDef(tileJSON.scheme)) { if (tileJSON.scheme !== undefined) {
goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"'); goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
} }
var minZoom = tileJSON.minzoom || 0; var minZoom = tileJSON.minzoom || 0;

View File

@@ -110,13 +110,13 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
var sourceProjection = this.getProjection(); var sourceProjection = this.getProjection();
var extent; var extent;
if (goog.isDef(tileJSON.bounds)) { if (tileJSON.bounds !== undefined) {
var transform = ol.proj.getTransformFromProjections( var transform = ol.proj.getTransformFromProjections(
epsg4326Projection, sourceProjection); epsg4326Projection, sourceProjection);
extent = ol.extent.applyTransform(tileJSON.bounds, transform); extent = ol.extent.applyTransform(tileJSON.bounds, transform);
} }
if (goog.isDef(tileJSON.scheme)) { if (tileJSON.scheme !== undefined) {
goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"'); goog.asserts.assert(tileJSON.scheme == 'xyz', 'tileJSON-scheme is "xyz"');
} }
var minZoom = tileJSON.minzoom || 0; var minZoom = tileJSON.minzoom || 0;
@@ -138,7 +138,7 @@ ol.source.TileUTFGrid.prototype.handleTileJSONResponse = function(tileJSON) {
this.tileUrlFunction_ = ol.TileUrlFunction.createFromTemplates(grids); this.tileUrlFunction_ = ol.TileUrlFunction.createFromTemplates(grids);
if (goog.isDef(tileJSON.attribution)) { if (tileJSON.attribution !== undefined) {
var attributionExtent = goog.isDef(extent) ? var attributionExtent = goog.isDef(extent) ?
extent : epsg4326Projection.getExtent(); extent : epsg4326Projection.getExtent();
/** @type {Object.<string, Array.<ol.TileRange>>} */ /** @type {Object.<string, Array.<ol.TileRange>>} */

View File

@@ -67,11 +67,11 @@ ol.source.TileVector = function(options) {
*/ */
this.tiles_ = {}; this.tiles_ = {};
if (goog.isDef(options.tileUrlFunction)) { if (options.tileUrlFunction !== undefined) {
this.setTileUrlFunction(options.tileUrlFunction); this.setTileUrlFunction(options.tileUrlFunction);
} else if (goog.isDef(options.urls)) { } else if (options.urls !== undefined) {
this.setUrls(options.urls); this.setUrls(options.urls);
} else if (goog.isDef(options.url)) { } else if (options.url !== undefined) {
this.setUrl(options.url); this.setUrl(options.url);
} }

View File

@@ -91,9 +91,9 @@ ol.source.Vector = function(opt_options) {
*/ */
this.loader_ = goog.nullFunction; this.loader_ = goog.nullFunction;
if (goog.isDef(options.loader)) { if (options.loader !== undefined) {
this.loader_ = options.loader; this.loader_ = options.loader;
} else if (goog.isDef(options.url)) { } else if (options.url !== undefined) {
goog.asserts.assert(goog.isDef(options.format), goog.asserts.assert(goog.isDef(options.format),
'format must be set when url is set'); 'format must be set when url is set');
// create a XHR feature loader for "url" and "format" // create a XHR feature loader for "url" and "format"

View File

@@ -56,11 +56,11 @@ ol.source.XYZ = function(options) {
wrapX: goog.isDef(options.wrapX) ? options.wrapX : true wrapX: goog.isDef(options.wrapX) ? options.wrapX : true
}); });
if (goog.isDef(options.tileUrlFunction)) { if (options.tileUrlFunction !== undefined) {
this.setTileUrlFunction(options.tileUrlFunction); this.setTileUrlFunction(options.tileUrlFunction);
} else if (goog.isDef(options.urls)) { } else if (options.urls !== undefined) {
this.setUrls(options.urls); this.setUrls(options.urls);
} else if (goog.isDef(options.url)) { } else if (options.url !== undefined) {
this.setUrl(options.url); this.setUrl(options.url);
} }

View File

@@ -40,7 +40,7 @@ ol.style.Style = function(opt_options) {
*/ */
this.geometryFunction_ = ol.style.defaultGeometryFunction; this.geometryFunction_ = ol.style.defaultGeometryFunction;
if (goog.isDef(options.geometry)) { if (options.geometry !== undefined) {
this.setGeometry(options.geometry); this.setGeometry(options.geometry);
} }

View File

@@ -64,7 +64,7 @@ ol.tilegrid.TileGrid = function(options) {
* @type {Array.<ol.Coordinate>} * @type {Array.<ol.Coordinate>}
*/ */
this.origins_ = null; this.origins_ = null;
if (goog.isDef(options.origins)) { if (options.origins !== undefined) {
this.origins_ = options.origins; this.origins_ = options.origins;
goog.asserts.assert(this.origins_.length == this.resolutions_.length, goog.asserts.assert(this.origins_.length == this.resolutions_.length,
'number of origins and resolutions must be equal'); 'number of origins and resolutions must be equal');
@@ -87,7 +87,7 @@ ol.tilegrid.TileGrid = function(options) {
* @type {Array.<number|ol.Size>} * @type {Array.<number|ol.Size>}
*/ */
this.tileSizes_ = null; this.tileSizes_ = null;
if (goog.isDef(options.tileSizes)) { if (options.tileSizes !== undefined) {
this.tileSizes_ = options.tileSizes; this.tileSizes_ = options.tileSizes;
goog.asserts.assert(this.tileSizes_.length == this.resolutions_.length, goog.asserts.assert(this.tileSizes_.length == this.resolutions_.length,
'number of tileSizes and resolutions must be equal'); 'number of tileSizes and resolutions must be equal');
@@ -118,7 +118,7 @@ ol.tilegrid.TileGrid = function(options) {
*/ */
this.fullTileRanges_ = null; this.fullTileRanges_ = null;
if (goog.isDef(options.sizes)) { if (options.sizes !== undefined) {
goog.asserts.assert(options.sizes.length == this.resolutions_.length, goog.asserts.assert(options.sizes.length == this.resolutions_.length,
'number of sizes and resolutions must be equal'); 'number of sizes and resolutions must be equal');
this.fullTileRanges_ = goog.array.map(options.sizes, function(size, z) { this.fullTileRanges_ = goog.array.map(options.sizes, function(size, z) {

View File

@@ -154,9 +154,9 @@ ol.View = function(opt_options) {
this.constraints_ = new ol.Constraints( this.constraints_ = new ol.Constraints(
centerConstraint, resolutionConstraint, rotationConstraint); centerConstraint, resolutionConstraint, rotationConstraint);
if (goog.isDef(options.resolution)) { if (options.resolution !== undefined) {
properties[ol.ViewProperty.RESOLUTION] = options.resolution; properties[ol.ViewProperty.RESOLUTION] = options.resolution;
} else if (goog.isDef(options.zoom)) { } else if (options.zoom !== undefined) {
properties[ol.ViewProperty.RESOLUTION] = this.constrainResolution( properties[ol.ViewProperty.RESOLUTION] = this.constrainResolution(
this.maxResolution_, options.zoom - this.minZoom_); this.maxResolution_, options.zoom - this.minZoom_);
} }
@@ -463,9 +463,9 @@ ol.View.prototype.fit = function(geometry, size, opt_options) {
options.constrainResolution : true; options.constrainResolution : true;
var nearest = goog.isDef(options.nearest) ? options.nearest : false; var nearest = goog.isDef(options.nearest) ? options.nearest : false;
var minResolution; var minResolution;
if (goog.isDef(options.minResolution)) { if (options.minResolution !== undefined) {
minResolution = options.minResolution; minResolution = options.minResolution;
} else if (goog.isDef(options.maxZoom)) { } else if (options.maxZoom !== undefined) {
minResolution = this.constrainResolution( minResolution = this.constrainResolution(
this.maxResolution_, options.maxZoom - this.minZoom_, 0); this.maxResolution_, options.maxZoom - this.minZoom_, 0);
} else { } else {
@@ -638,7 +638,7 @@ ol.View.prototype.setZoom = function(zoom) {
* @return {ol.CenterConstraintType} * @return {ol.CenterConstraintType}
*/ */
ol.View.createCenterConstraint_ = function(options) { ol.View.createCenterConstraint_ = function(options) {
if (goog.isDef(options.extent)) { if (options.extent !== undefined) {
return ol.CenterConstraint.createExtent(options.extent); return ol.CenterConstraint.createExtent(options.extent);
} else { } else {
return ol.CenterConstraint.none; return ol.CenterConstraint.none;
@@ -671,7 +671,7 @@ ol.View.createResolutionConstraint_ = function(options) {
var zoomFactor = goog.isDef(options.zoomFactor) ? var zoomFactor = goog.isDef(options.zoomFactor) ?
options.zoomFactor : defaultZoomFactor; options.zoomFactor : defaultZoomFactor;
if (goog.isDef(options.resolutions)) { if (options.resolutions !== undefined) {
var resolutions = options.resolutions; var resolutions = options.resolutions;
maxResolution = resolutions[0]; maxResolution = resolutions[0];
minResolution = resolutions[resolutions.length - 1]; minResolution = resolutions[resolutions.length - 1];
@@ -704,8 +704,8 @@ ol.View.createResolutionConstraint_ = function(options) {
// user provided minResolution takes precedence // user provided minResolution takes precedence
minResolution = options.minResolution; minResolution = options.minResolution;
if (!goog.isDef(minResolution)) { if (!goog.isDef(minResolution)) {
if (goog.isDef(options.maxZoom)) { if (options.maxZoom !== undefined) {
if (goog.isDef(options.maxResolution)) { if (options.maxResolution !== undefined) {
minResolution = maxResolution / Math.pow(zoomFactor, maxZoom); minResolution = maxResolution / Math.pow(zoomFactor, maxZoom);
} else { } else {
minResolution = defaultMaxResolution / Math.pow(zoomFactor, maxZoom); minResolution = defaultMaxResolution / Math.pow(zoomFactor, maxZoom);