Files
openlayers/src/ol/base/mapbrowserevent.js
2012-07-29 17:09:32 +02:00

51 lines
1.1 KiB
JavaScript

goog.provide('ol.MapBrowserEvent');
goog.require('goog.events.BrowserEvent');
goog.require('ol.Coordinate');
goog.require('ol.MapEvent');
goog.require('ol.Pixel');
/**
* @constructor
* @extends {ol.MapEvent}
* @param {string} type Event type.
* @param {ol.Map} map Map.
* @param {goog.events.BrowserEvent} browserEvent Browser event.
*/
ol.MapBrowserEvent = function(type, map, browserEvent) {
goog.base(this, type, map);
/**
* @type {goog.events.BrowserEvent}
*/
this.browserEvent = browserEvent;
};
goog.inherits(ol.MapBrowserEvent, ol.MapEvent);
/**
* @private
* @type {ol.Coordinate|undefined}
*/
ol.MapBrowserEvent.prototype.coordinate_;
/**
* @return {ol.Coordinate|undefined} Coordinate.
*/
ol.MapBrowserEvent.prototype.getCoordinate = function() {
if (goog.isDef(this.coordinate_)) {
return this.coordinate_;
} else {
var browserEvent = this.browserEvent;
var pixel = new ol.Pixel(browserEvent.offsetX, browserEvent.offsetY);
var coordinate = this.map.getCoordinateFromPixel(pixel);
this.coordinate_ = coordinate;
return coordinate;
}
};