Using null instead of null or object or undefined

This commit is contained in:
Tim Schaub
2012-09-28 12:06:34 +02:00
parent 3e34013c09
commit eb29e6a43c
3 changed files with 10 additions and 20 deletions
+7 -13
View File
@@ -32,9 +32,9 @@ ol.MapBrowserEvent = function(type, map, browserEvent) {
/**
* @private
* @type {ol.Coordinate|undefined}
* @type {ol.Coordinate}
*/
this.coordinate_ = undefined;
this.coordinate_ = null;
/**
* @private
@@ -47,17 +47,13 @@ goog.inherits(ol.MapBrowserEvent, ol.MapEvent);
/**
* @return {ol.Coordinate|undefined} Coordinate.
* @return {ol.Coordinate} Coordinate.
*/
ol.MapBrowserEvent.prototype.getCoordinate = function() {
if (goog.isDef(this.coordinate_)) {
return this.coordinate_;
} else {
var pixel = this.getPixel();
var coordinate = this.map.getCoordinateFromPixel(pixel);
this.coordinate_ = coordinate;
return coordinate;
if (goog.isNull(this.coordinate_)) {
this.coordinate_ = this.map.getCoordinateFromPixel(this.getPixel());
}
return this.coordinate_;
};
@@ -67,10 +63,8 @@ ol.MapBrowserEvent.prototype.getCoordinate = function() {
*/
ol.MapBrowserEvent.prototype.getPixel = function() {
if (goog.isNull(this.pixel_)) {
var map = this.map;
var browserEvent = this.browserEvent;
var eventPosition = goog.style.getRelativePosition(
browserEvent, map.getViewport());
this.browserEvent, this.map.getViewport());
this.pixel_ = new ol.Pixel(eventPosition.x, eventPosition.y);
}
return this.pixel_;