conversions to/from lonlat/px need to take into account
the offset of the layersContainerDiv. 


I have introduced the following functions for converting
between layer and screen pixel values:

getLayerPxFromScreenPx() and getScreenPxFromLayerPx()

they are pretty self-explanitory.


I then renamed:

getPixelFromLonLat() and getLonLatFromPixel()

to:

getScreenPxFromLonLat() and getLonLatFroScreenmPx()

and added:

getLayerPxFromLonLat() and getLonLatFromLayerPx()


updates were made throughout the code, demos, and tests
so everything should still run smoothly.

-e-

git-svn-id: http://svn.openlayers.org/trunk/openlayers@329 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-05-24 18:45:50 +00:00
parent e5bb6b7dbd
commit 06cbeb2f11
5 changed files with 93 additions and 21 deletions

View File

@@ -19,7 +19,7 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt
*/
defaultDblClick: function (evt) {
var newCenter = this.map.getLonLatFromPixel( evt.xy );
var newCenter = this.map.getLonLatFromScreenPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 1);
},
@@ -68,7 +68,7 @@ OpenLayers.Control.MouseDefaults.prototype =
var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromPixel( newXY );
var newCenter = this.map.getLonLatFromScreenPx( newXY );
this.map.setCenter(newCenter);
this.mouseDragStart = evt.xy.copyOf();
}
@@ -80,8 +80,8 @@ OpenLayers.Control.MouseDefaults.prototype =
*/
defaultMouseUp: function (evt) {
if (this.zoomBox) {
var start = this.map.getLonLatFromPixel( this.mouseDragStart );
var end = this.map.getLonLatFromPixel( evt.xy );
var start = this.map.getLonLatFromScreenPx( this.mouseDragStart );
var end = this.map.getLonLatFromScreenPx( evt.xy );
var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon);