change function name from ScreenPx to ViewPortPx

git-svn-id: http://svn.openlayers.org/trunk/openlayers@630 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
euzuro
2006-06-20 22:51:55 +00:00
parent 7ebaf2a630
commit ed3c2a6f0b
6 changed files with 17 additions and 17 deletions

View File

@@ -26,7 +26,7 @@
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.events.register("click", map, function(e) {
var lonlat = map.getLonLatFromScreenPx(e.xy);
var lonlat = map.getLonLatFromViewPortPx(e.xy);
alert("You clicked near " + lonlat.lat + " N, " +
+ lonlat.lon + " E");
});

View File

@@ -41,8 +41,8 @@
function changer() {
var lon = map.getLonLatFromLayerPx(new OpenLayers.Pixel(0,0)).lon;
var lat = map.getLonLatFromLayerPx(new OpenLayers.Pixel(0,0)).lat;
var slon = map.getLonLatFromScreenPx(new OpenLayers.Pixel(0,0)).lon;
var slat = map.getLonLatFromScreenPx(new OpenLayers.Pixel(0,0)).lat;
var slon = map.getLonLatFromViewPortPx(new OpenLayers.Pixel(0,0)).lon;
var slat = map.getLonLatFromViewPortPx(new OpenLayers.Pixel(0,0)).lat;
alert("lon=" + lon + " lat=" + lat
+ "slon=" + slon + " slat=" + slat);
}

View File

@@ -28,7 +28,7 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt
*/
defaultDblClick: function (evt) {
var newCenter = this.map.getLonLatFromScreenPx( evt.xy );
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 1);
},
@@ -77,7 +77,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.getLonLatFromScreenPx( newXY );
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, true);
this.mouseDragStart = evt.xy.copyOf();
this.map.div.style.cursor = "move";
@@ -91,8 +91,8 @@ OpenLayers.Control.MouseDefaults.prototype =
*/
defaultMouseUp: function (evt) {
if (this.zoomBox) {
var start = this.map.getLonLatFromScreenPx( this.mouseDragStart );
var end = this.map.getLonLatFromScreenPx( evt.xy );
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( 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);

View File

@@ -85,7 +85,7 @@ OpenLayers.Control.MouseToolbar.prototype =
*/
defaultDblClick: function (evt) {
this.switchModeTo("pan");
var newCenter = this.map.getLonLatFromScreenPx( evt.xy );
var newCenter = this.map.getLonLatFromViewPortPx( evt.xy );
this.map.setCenter(newCenter, this.map.zoom + 2);
},
@@ -120,13 +120,13 @@ OpenLayers.Control.MouseToolbar.prototype =
case "measure":
var distance = "";
if (this.measureStart) {
measureEnd = this.map.getLonLatFromScreenPx(this.mouseDragStart);
measureEnd = this.map.getLonLatFromViewPortPx(this.mouseDragStart);
distance = OpenLayers.Util.distVincenty(this.measureStart, measureEnd);
distance = Math.round(distance * 100) / 100;
distance = distance + "km";
this.measureStartBox = this.measureBox;
}
this.measureStart = this.map.getLonLatFromScreenPx(this.mouseDragStart);;
this.measureStart = this.map.getLonLatFromViewPortPx(this.mouseDragStart);;
this.measureBox = OpenLayers.Util.createDiv(null,
this.mouseDragStart.add(
-2-parseInt(this.map.layerContainerDiv.style.left),
@@ -211,7 +211,7 @@ OpenLayers.Control.MouseToolbar.prototype =
var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromScreenPx( newXY );
var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, true);
this.mouseDragStart = evt.xy.copyOf();
}
@@ -224,8 +224,8 @@ OpenLayers.Control.MouseToolbar.prototype =
defaultMouseUp: function (evt) {
switch (this.mode) {
case "zoombox":
var start = this.map.getLonLatFromScreenPx( this.mouseDragStart );
var end = this.map.getLonLatFromScreenPx( evt.xy );
var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromViewPortPx( 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);

View File

@@ -352,7 +352,7 @@ OpenLayers.Map.prototype = {
getLonLatFromLayerPx: function (px) {
//adjust for displacement of layerContainerDiv
px = this.getScreenPxFromLayerPx(px);
return this.getLonLatFromScreenPx(px);
return this.getLonLatFromViewPortPx(px);
},
/**
@@ -363,7 +363,7 @@ OpenLayers.Map.prototype = {
* current extent and resolution
* @type OpenLayers.LonLat
*/
getLonLatFromScreenPx: function (screenPx) {
getLonLatFromViewPortPx: function (screenPx) {
var center = this.getCenter(); //map center lon/lat
var res = this.getResolution();
var size = this.getSize();

View File

@@ -125,8 +125,8 @@
map.setCenter(new OpenLayers.LonLat(0, 0), 0);
var pixel = new OpenLayers.Pixel(50,150);
var lonlat = map.getLonLatFromScreenPx(pixel);
t.ok( lonlat instanceof OpenLayers.LonLat, "getLonLatFromScreenPx returns valid OpenLayers.LonLat" );
var lonlat = map.getLonLatFromViewPortPx(pixel);
t.ok( lonlat instanceof OpenLayers.LonLat, "getLonLatFromViewPortPx returns valid OpenLayers.LonLat" );
var newPixel = map.getScreenPxFromLonLat(lonlat);
t.ok( newPixel instanceof OpenLayers.Pixel, "getScreenPxFromLonLat returns valid OpenLayers.Pixel" );