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
+1 -1
View File
@@ -26,7 +26,7 @@
map.addControl(new OpenLayers.Control.LayerSwitcher()); map.addControl(new OpenLayers.Control.LayerSwitcher());
map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.setCenter(new OpenLayers.LonLat(0, 0), 0);
map.events.register("click", map, function(e) { 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, " + alert("You clicked near " + lonlat.lat + " N, " +
+ lonlat.lon + " E"); + lonlat.lon + " E");
}); });
+2 -2
View File
@@ -41,8 +41,8 @@
function changer() { function changer() {
var lon = map.getLonLatFromLayerPx(new OpenLayers.Pixel(0,0)).lon; var lon = map.getLonLatFromLayerPx(new OpenLayers.Pixel(0,0)).lon;
var lat = map.getLonLatFromLayerPx(new OpenLayers.Pixel(0,0)).lat; var lat = map.getLonLatFromLayerPx(new OpenLayers.Pixel(0,0)).lat;
var slon = map.getLonLatFromScreenPx(new OpenLayers.Pixel(0,0)).lon; var slon = map.getLonLatFromViewPortPx(new OpenLayers.Pixel(0,0)).lon;
var slat = map.getLonLatFromScreenPx(new OpenLayers.Pixel(0,0)).lat; var slat = map.getLonLatFromViewPortPx(new OpenLayers.Pixel(0,0)).lat;
alert("lon=" + lon + " lat=" + lat alert("lon=" + lon + " lat=" + lat
+ "slon=" + slon + " slat=" + slat); + "slon=" + slon + " slat=" + slat);
} }
+4 -4
View File
@@ -28,7 +28,7 @@ OpenLayers.Control.MouseDefaults.prototype =
* @param {Event} evt * @param {Event} evt
*/ */
defaultDblClick: function (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); this.map.setCenter(newCenter, this.map.zoom + 1);
}, },
@@ -77,7 +77,7 @@ OpenLayers.Control.MouseDefaults.prototype =
var size = this.map.getSize(); var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY); size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromScreenPx( newXY ); var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, true); this.map.setCenter(newCenter, null, true);
this.mouseDragStart = evt.xy.copyOf(); this.mouseDragStart = evt.xy.copyOf();
this.map.div.style.cursor = "move"; this.map.div.style.cursor = "move";
@@ -91,8 +91,8 @@ OpenLayers.Control.MouseDefaults.prototype =
*/ */
defaultMouseUp: function (evt) { defaultMouseUp: function (evt) {
if (this.zoomBox) { if (this.zoomBox) {
var start = this.map.getLonLatFromScreenPx( this.mouseDragStart ); var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromScreenPx( evt.xy ); var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat); var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat); var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon); var left = Math.min(start.lon, end.lon);
+6 -6
View File
@@ -85,7 +85,7 @@ OpenLayers.Control.MouseToolbar.prototype =
*/ */
defaultDblClick: function (evt) { defaultDblClick: function (evt) {
this.switchModeTo("pan"); 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); this.map.setCenter(newCenter, this.map.zoom + 2);
}, },
@@ -120,13 +120,13 @@ OpenLayers.Control.MouseToolbar.prototype =
case "measure": case "measure":
var distance = ""; var distance = "";
if (this.measureStart) { if (this.measureStart) {
measureEnd = this.map.getLonLatFromScreenPx(this.mouseDragStart); measureEnd = this.map.getLonLatFromViewPortPx(this.mouseDragStart);
distance = OpenLayers.Util.distVincenty(this.measureStart, measureEnd); distance = OpenLayers.Util.distVincenty(this.measureStart, measureEnd);
distance = Math.round(distance * 100) / 100; distance = Math.round(distance * 100) / 100;
distance = distance + "km"; distance = distance + "km";
this.measureStartBox = this.measureBox; 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.measureBox = OpenLayers.Util.createDiv(null,
this.mouseDragStart.add( this.mouseDragStart.add(
-2-parseInt(this.map.layerContainerDiv.style.left), -2-parseInt(this.map.layerContainerDiv.style.left),
@@ -211,7 +211,7 @@ OpenLayers.Control.MouseToolbar.prototype =
var size = this.map.getSize(); var size = this.map.getSize();
var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX, var newXY = new OpenLayers.Pixel(size.w / 2 + deltaX,
size.h / 2 + deltaY); size.h / 2 + deltaY);
var newCenter = this.map.getLonLatFromScreenPx( newXY ); var newCenter = this.map.getLonLatFromViewPortPx( newXY );
this.map.setCenter(newCenter, null, true); this.map.setCenter(newCenter, null, true);
this.mouseDragStart = evt.xy.copyOf(); this.mouseDragStart = evt.xy.copyOf();
} }
@@ -224,8 +224,8 @@ OpenLayers.Control.MouseToolbar.prototype =
defaultMouseUp: function (evt) { defaultMouseUp: function (evt) {
switch (this.mode) { switch (this.mode) {
case "zoombox": case "zoombox":
var start = this.map.getLonLatFromScreenPx( this.mouseDragStart ); var start = this.map.getLonLatFromViewPortPx( this.mouseDragStart );
var end = this.map.getLonLatFromScreenPx( evt.xy ); var end = this.map.getLonLatFromViewPortPx( evt.xy );
var top = Math.max(start.lat, end.lat); var top = Math.max(start.lat, end.lat);
var bottom = Math.min(start.lat, end.lat); var bottom = Math.min(start.lat, end.lat);
var left = Math.min(start.lon, end.lon); var left = Math.min(start.lon, end.lon);
+2 -2
View File
@@ -352,7 +352,7 @@ OpenLayers.Map.prototype = {
getLonLatFromLayerPx: function (px) { getLonLatFromLayerPx: function (px) {
//adjust for displacement of layerContainerDiv //adjust for displacement of layerContainerDiv
px = this.getScreenPxFromLayerPx(px); px = this.getScreenPxFromLayerPx(px);
return this.getLonLatFromScreenPx(px); return this.getLonLatFromViewPortPx(px);
}, },
/** /**
@@ -363,7 +363,7 @@ OpenLayers.Map.prototype = {
* current extent and resolution * current extent and resolution
* @type OpenLayers.LonLat * @type OpenLayers.LonLat
*/ */
getLonLatFromScreenPx: function (screenPx) { getLonLatFromViewPortPx: function (screenPx) {
var center = this.getCenter(); //map center lon/lat var center = this.getCenter(); //map center lon/lat
var res = this.getResolution(); var res = this.getResolution();
var size = this.getSize(); var size = this.getSize();
+2 -2
View File
@@ -125,8 +125,8 @@
map.setCenter(new OpenLayers.LonLat(0, 0), 0); map.setCenter(new OpenLayers.LonLat(0, 0), 0);
var pixel = new OpenLayers.Pixel(50,150); var pixel = new OpenLayers.Pixel(50,150);
var lonlat = map.getLonLatFromScreenPx(pixel); var lonlat = map.getLonLatFromViewPortPx(pixel);
t.ok( lonlat instanceof OpenLayers.LonLat, "getLonLatFromScreenPx returns valid OpenLayers.LonLat" ); t.ok( lonlat instanceof OpenLayers.LonLat, "getLonLatFromViewPortPx returns valid OpenLayers.LonLat" );
var newPixel = map.getScreenPxFromLonLat(lonlat); var newPixel = map.getScreenPxFromLonLat(lonlat);
t.ok( newPixel instanceof OpenLayers.Pixel, "getScreenPxFromLonLat returns valid OpenLayers.Pixel" ); t.ok( newPixel instanceof OpenLayers.Pixel, "getScreenPxFromLonLat returns valid OpenLayers.Pixel" );