Using null instead of null or object or undefined
This commit is contained in:
@@ -108,7 +108,7 @@ ol.control.MousePosition.prototype.handleMouseMove = function(browserEvent) {
|
|||||||
var pixel = new ol.Pixel(eventPosition.x, eventPosition.y);
|
var pixel = new ol.Pixel(eventPosition.x, eventPosition.y);
|
||||||
var coordinate = map.getCoordinateFromPixel(pixel);
|
var coordinate = map.getCoordinateFromPixel(pixel);
|
||||||
var html;
|
var html;
|
||||||
if (goog.isDef(coordinate)) {
|
if (!goog.isNull(coordinate)) {
|
||||||
coordinate = this.transform_(coordinate);
|
coordinate = this.transform_(coordinate);
|
||||||
if (goog.isDef(this.coordinateFormat_)) {
|
if (goog.isDef(this.coordinateFormat_)) {
|
||||||
html = this.coordinateFormat_(coordinate);
|
html = this.coordinateFormat_(coordinate);
|
||||||
|
|||||||
+2
-6
@@ -282,14 +282,10 @@ ol.Map.prototype.getContainer = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {ol.Pixel} pixel Pixel.
|
* @param {ol.Pixel} pixel Pixel.
|
||||||
* @return {ol.Coordinate|undefined} Coordinate.
|
* @return {ol.Coordinate} Coordinate.
|
||||||
*/
|
*/
|
||||||
ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
|
ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
|
||||||
if (this.isDef()) {
|
return this.isDef() ? this.renderer_.getCoordinateFromPixel(pixel) : null;
|
||||||
return this.renderer_.getCoordinateFromPixel(pixel);
|
|
||||||
} else {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -32,9 +32,9 @@ ol.MapBrowserEvent = function(type, map, browserEvent) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.Coordinate|undefined}
|
* @type {ol.Coordinate}
|
||||||
*/
|
*/
|
||||||
this.coordinate_ = undefined;
|
this.coordinate_ = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @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() {
|
ol.MapBrowserEvent.prototype.getCoordinate = function() {
|
||||||
if (goog.isDef(this.coordinate_)) {
|
if (goog.isNull(this.coordinate_)) {
|
||||||
return this.coordinate_;
|
this.coordinate_ = this.map.getCoordinateFromPixel(this.getPixel());
|
||||||
} else {
|
|
||||||
var pixel = this.getPixel();
|
|
||||||
var coordinate = this.map.getCoordinateFromPixel(pixel);
|
|
||||||
this.coordinate_ = coordinate;
|
|
||||||
return coordinate;
|
|
||||||
}
|
}
|
||||||
|
return this.coordinate_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -67,10 +63,8 @@ ol.MapBrowserEvent.prototype.getCoordinate = function() {
|
|||||||
*/
|
*/
|
||||||
ol.MapBrowserEvent.prototype.getPixel = function() {
|
ol.MapBrowserEvent.prototype.getPixel = function() {
|
||||||
if (goog.isNull(this.pixel_)) {
|
if (goog.isNull(this.pixel_)) {
|
||||||
var map = this.map;
|
|
||||||
var browserEvent = this.browserEvent;
|
|
||||||
var eventPosition = goog.style.getRelativePosition(
|
var eventPosition = goog.style.getRelativePosition(
|
||||||
browserEvent, map.getViewport());
|
this.browserEvent, this.map.getViewport());
|
||||||
this.pixel_ = new ol.Pixel(eventPosition.x, eventPosition.y);
|
this.pixel_ = new ol.Pixel(eventPosition.x, eventPosition.y);
|
||||||
}
|
}
|
||||||
return this.pixel_;
|
return this.pixel_;
|
||||||
|
|||||||
Reference in New Issue
Block a user