Use map.getLonLatFromPixel instead of map.getLonLatFromViewPortPx
The former is the API method.
This commit is contained in:
+2
-2
@@ -34,7 +34,7 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
trigger: function(e) {
|
trigger: function(e) {
|
||||||
var lonlat = map.getLonLatFromViewPortPx(e.xy);
|
var lonlat = map.getLonLatFromPixel(e.xy);
|
||||||
alert("You clicked near " + lonlat.lat + " N, " +
|
alert("You clicked near " + lonlat.lat + " N, " +
|
||||||
+ lonlat.lon + " E");
|
+ lonlat.lon + " E");
|
||||||
}
|
}
|
||||||
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
<p id="shortdesc">
|
<p id="shortdesc">
|
||||||
This example shows the use of the click handler and
|
This example shows the use of the click handler and
|
||||||
getLonLatFromViewPortPx functions to trigger events on mouse click.
|
getLonLatFromPixel functions to trigger events on mouse click.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<div id="map" class="smallmap"></div>
|
<div id="map" class="smallmap"></div>
|
||||||
|
|||||||
@@ -99,7 +99,7 @@
|
|||||||
|
|
||||||
var pixel = new OpenLayers.Pixel(center.x + x, center.y + y);
|
var pixel = new OpenLayers.Pixel(center.x + x, center.y + y);
|
||||||
|
|
||||||
var lonLat = map.getLonLatFromViewPortPx(pixel);
|
var lonLat = map.getLonLatFromPixel(pixel);
|
||||||
features.push(
|
features.push(
|
||||||
new OpenLayers.Feature.Vector(
|
new OpenLayers.Feature.Vector(
|
||||||
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
|
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
|
||||||
|
|||||||
@@ -73,7 +73,7 @@
|
|||||||
// from bottom to top so as to quickly signal whether or not y-ordering is working.
|
// from bottom to top so as to quickly signal whether or not y-ordering is working.
|
||||||
while (bottom.y > top.y) {
|
while (bottom.y > top.y) {
|
||||||
bottom.y -= POINT_DISTANCE;
|
bottom.y -= POINT_DISTANCE;
|
||||||
var lonLat = map.getLonLatFromViewPortPx(bottom);
|
var lonLat = map.getLonLatFromPixel(bottom);
|
||||||
orderingFeatures.push(
|
orderingFeatures.push(
|
||||||
new OpenLayers.Feature.Vector(
|
new OpenLayers.Feature.Vector(
|
||||||
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
|
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
var indexFeatures = [];
|
var indexFeatures = [];
|
||||||
var useFirst = true;
|
var useFirst = true;
|
||||||
while (left.x <= right.x) {
|
while (left.x <= right.x) {
|
||||||
var lonLat = map.getLonLatFromViewPortPx(left);
|
var lonLat = map.getLonLatFromPixel(left);
|
||||||
var point = new OpenLayers.Feature.Vector(
|
var point = new OpenLayers.Feature.Vector(
|
||||||
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
|
new OpenLayers.Geometry.Point(lonLat.lon, lonLat.lat)
|
||||||
);
|
);
|
||||||
@@ -147,8 +147,8 @@
|
|||||||
// and succomb to y-ordering.
|
// and succomb to y-ordering.
|
||||||
var orderingFeatures = [];
|
var orderingFeatures = [];
|
||||||
while (bottom.y > top.y && left.x < right.x) {
|
while (bottom.y > top.y && left.x < right.x) {
|
||||||
var bottomLonLat = map.getLonLatFromViewPortPx(bottom);
|
var bottomLonLat = map.getLonLatFromPixel(bottom);
|
||||||
var leftLonLat = map.getLonLatFromViewPortPx(left);
|
var leftLonLat = map.getLonLatFromPixel(left);
|
||||||
orderingFeatures.push(
|
orderingFeatures.push(
|
||||||
new OpenLayers.Feature.Vector(
|
new OpenLayers.Feature.Vector(
|
||||||
new OpenLayers.Geometry.Point(leftLonLat.lon, bottomLonLat.lat),
|
new OpenLayers.Geometry.Point(leftLonLat.lon, bottomLonLat.lat),
|
||||||
|
|||||||
Reference in New Issue
Block a user