Make ol.Map#setView do not accept undefined
With this change map.setView(null) is permitted, but map.setView(undefined) is not. map.getView now always returns a defined value, which may be null is setView was called with null.
This commit is contained in:
@@ -130,7 +130,7 @@ ol.control.Rotate.prototype.handlePointerUp_ = function(pointerEvent) {
|
||||
ol.control.Rotate.prototype.resetNorth_ = function() {
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(!goog.isNull(view));
|
||||
var currentRotation = view.getRotation();
|
||||
while (currentRotation < -Math.PI) {
|
||||
currentRotation += 2 * Math.PI;
|
||||
|
||||
@@ -50,7 +50,7 @@ ol.interaction.DoubleClickZoom.prototype.handleMapBrowserEvent =
|
||||
var anchor = mapBrowserEvent.coordinate;
|
||||
var delta = browserEvent.shiftKey ? -this.delta_ : this.delta_;
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(!goog.isNull(view));
|
||||
ol.interaction.Interaction.zoomByDelta(
|
||||
map, view, delta, anchor, this.duration_);
|
||||
mapBrowserEvent.preventDefault();
|
||||
|
||||
@@ -100,7 +100,7 @@ ol.interaction.DragAndDrop.prototype.handleResult_ = function(file, result) {
|
||||
var projection = this.reprojectTo_;
|
||||
if (goog.isNull(projection)) {
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(!goog.isNull(view));
|
||||
projection = view.getProjection();
|
||||
goog.asserts.assert(goog.isDef(projection));
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ goog.inherits(ol.interaction.DragZoom, ol.interaction.DragBox);
|
||||
ol.interaction.DragZoom.prototype.onBoxEnd = function() {
|
||||
var map = this.getMap();
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(!goog.isNull(view));
|
||||
var extent = this.getGeometry().getExtent();
|
||||
var center = ol.extent.getCenter(extent);
|
||||
var size = map.getSize();
|
||||
|
||||
@@ -70,7 +70,7 @@ ol.interaction.KeyboardPan.prototype.handleMapBrowserEvent =
|
||||
keyCode == goog.events.KeyCodes.UP)) {
|
||||
var map = mapBrowserEvent.map;
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(!goog.isNull(view));
|
||||
var viewState = view.getState();
|
||||
var mapUnitsDelta = viewState.resolution * this.pixelDelta_;
|
||||
var deltaX = 0, deltaY = 0;
|
||||
|
||||
@@ -70,7 +70,7 @@ ol.interaction.KeyboardZoom.prototype.handleMapBrowserEvent =
|
||||
var delta = (charCode == '+'.charCodeAt(0)) ? this.delta_ : -this.delta_;
|
||||
map.render();
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(!goog.isNull(view));
|
||||
ol.interaction.Interaction.zoomByDelta(
|
||||
map, view, delta, undefined, this.duration_);
|
||||
mapBrowserEvent.preventDefault();
|
||||
|
||||
@@ -101,7 +101,7 @@ ol.interaction.MouseWheelZoom.prototype.doZoom_ = function(map) {
|
||||
var delta = goog.math.clamp(this.delta_, -maxDelta, maxDelta);
|
||||
|
||||
var view = map.getView();
|
||||
goog.asserts.assert(goog.isDef(view));
|
||||
goog.asserts.assert(!goog.isNull(view));
|
||||
|
||||
map.render();
|
||||
ol.interaction.Interaction.zoomByDelta(map, view, -delta, this.lastAnchor_,
|
||||
|
||||
@@ -753,7 +753,7 @@ goog.exportProperty(
|
||||
/**
|
||||
* Get the view associated with this map. A view manages properties such as
|
||||
* center and resolution.
|
||||
* @return {ol.View|undefined} The view that controls this map.
|
||||
* @return {ol.View} The view that controls this map.
|
||||
* @observable
|
||||
* @api stable
|
||||
*/
|
||||
@@ -988,7 +988,7 @@ ol.Map.prototype.handleViewChanged_ = function() {
|
||||
this.viewPropertyListenerKey_ = null;
|
||||
}
|
||||
var view = this.getView();
|
||||
if (goog.isDefAndNotNull(view)) {
|
||||
if (!goog.isNull(view)) {
|
||||
this.viewPropertyListenerKey_ = goog.events.listen(
|
||||
view, ol.ObjectEventType.PROPERTYCHANGE,
|
||||
this.handleViewPropertyChanged_, false, this);
|
||||
@@ -1061,7 +1061,7 @@ ol.Map.prototype.isDef = function() {
|
||||
return false;
|
||||
}
|
||||
var view = this.getView();
|
||||
if (!goog.isDef(view) || !view.isDef()) {
|
||||
if (goog.isNull(view) || !view.isDef()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -1189,7 +1189,7 @@ ol.Map.prototype.renderFrame_ = function(time) {
|
||||
/** @type {?olx.FrameState} */
|
||||
var frameState = null;
|
||||
if (goog.isDef(size) && hasArea(size) &&
|
||||
goog.isDef(view) && view.isDef()) {
|
||||
!goog.isNull(view) && view.isDef()) {
|
||||
var viewHints = view.getHints();
|
||||
var layerStatesArray = this.getLayerGroup().getLayerStatesArray();
|
||||
var layerStates = {};
|
||||
|
||||
Reference in New Issue
Block a user