Use ol.Pixel to represent pixels

This commit is contained in:
Tom Payne
2012-07-29 12:13:10 +02:00
parent 10c85f3d07
commit faa37490ea
2 changed files with 6 additions and 4 deletions

View File

@@ -36,6 +36,7 @@ goog.require('ol.Extent');
goog.require('ol.LayerRenderer');
goog.require('ol.MapBrowserEvent');
goog.require('ol.Object');
goog.require('ol.Pixel');
goog.require('ol.Projection');
goog.require('ol.Size');
goog.require('ol.TransformFunction');
@@ -330,7 +331,7 @@ ol.Map.prototype.getControls = function() {
/**
* @param {ol.Coordinate} pixel Pixel.
* @param {ol.Pixel} pixel Pixel.
* @return {ol.Coordinate|undefined} Coordinate.
*/
ol.Map.prototype.getCoordinateFromPixel = function(pixel) {
@@ -387,14 +388,14 @@ ol.Map.prototype.getLayers = function() {
/**
* @param {ol.Coordinate} coordinate Coordinate.
* @return {ol.Coordinate|undefined} Pixel.
* @return {ol.Pixel|undefined} Pixel.
*/
ol.Map.prototype.getPixelFromCoordinate = function(coordinate) {
if (this.isDef()) {
this.updateMatrices_();
var vec3 = [coordinate.x, coordinate.y, 0];
goog.vec.Mat4.multVec3(this.coordinateToPixelMatrix_, vec3, vec3);
return new ol.Coordinate(vec3[0], vec3[1]);
return new ol.Pixel(vec3[0], vec3[1]);
} else {
return undefined;
}

View File

@@ -3,6 +3,7 @@ goog.provide('ol.MapBrowserEvent');
goog.require('goog.events.BrowserEvent');
goog.require('ol.Coordinate');
goog.require('ol.MapEvent');
goog.require('ol.Pixel');
@@ -41,7 +42,7 @@ ol.MapBrowserEvent.prototype.getCoordinate = function() {
return this.coordinate_;
} else {
var browserEvent = this.browserEvent;
var pixel = new ol.Coordinate(browserEvent.offsetX, browserEvent.offsetY);
var pixel = new ol.Pixel(browserEvent.offsetX, browserEvent.offsetY);
var coordinate = this.map.getCoordinateFromPixel(pixel);
this.coordinate_ = coordinate;
return coordinate;