Making sketch handlers work over the dateline by using layer.getLonLatFromViewPortPx instead of map.getLonLatFromPixel. Thanks bartvde for the unit and acceptance tests. r=bartvde (closes #2787)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@12346 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1376,6 +1376,32 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_citeComplaint(t) {
|
||||
t.plan(2);
|
||||
var map = new OpenLayers.Map('map');
|
||||
map.addLayer(new OpenLayers.Layer.OSM());
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
map.addLayer(layer);
|
||||
var control = new OpenLayers.Control({});
|
||||
var handler = new OpenLayers.Handler.Path(control, {});
|
||||
control.handler = handler;
|
||||
map.addControl(control);
|
||||
map.zoomToExtent(new OpenLayers.Bounds(-24225034.496992, -11368938.517442, -14206280.326992, -1350184.3474418));
|
||||
handler.activate();
|
||||
handler.createFeature(new OpenLayers.Pixel(100, 50));
|
||||
t.ok(handler.point.geometry.x < 0, "Geometry started correctly when wrapping the dateline using citeCompliant false");
|
||||
control.deactivate();
|
||||
|
||||
handler = new OpenLayers.Handler.Path(control, {}, {citeCompliant: true});
|
||||
control.handler = handler;
|
||||
control.activate();
|
||||
handler.createFeature(new OpenLayers.Pixel(100, 50));
|
||||
t.ok(handler.point.geometry.x > 0, "Geometry started correctly when wrapping the dateline using citeCompliant true");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -1128,6 +1128,31 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_citeComplaint(t) {
|
||||
t.plan(2);
|
||||
var map = new OpenLayers.Map('map');
|
||||
map.addLayer(new OpenLayers.Layer.OSM());
|
||||
var layer = new OpenLayers.Layer.Vector();
|
||||
map.addLayer(layer);
|
||||
var control = new OpenLayers.Control({});
|
||||
var handler = new OpenLayers.Handler.Polygon(control, {});
|
||||
control.handler = handler;
|
||||
map.addControl(control);
|
||||
map.zoomToExtent(new OpenLayers.Bounds(-24225034.496992, -11368938.517442, -14206280.326992, -1350184.3474418));
|
||||
control.activate();
|
||||
handler.createFeature(new OpenLayers.Pixel(100, 50));
|
||||
t.ok(handler.point.geometry.x < 0, "Geometry started correctly when wrapping the dateline using citeCompliant false");
|
||||
control.deactivate();
|
||||
|
||||
var handler = new OpenLayers.Handler.Polygon(control, {}, {citeCompliant: true});
|
||||
control.handler = handler;
|
||||
control.activate();
|
||||
handler.createFeature(new OpenLayers.Pixel(100, 50));
|
||||
t.ok(handler.point.geometry.x > 0, "Geometry started correctly when wrapping the dateline using citeCompliant true");
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
@@ -149,9 +149,6 @@
|
||||
function test_Handler_RegularPolygon_irregular(t) {
|
||||
t.plan(4);
|
||||
var map = {
|
||||
getLonLatFromPixel: function(px) {
|
||||
return {lon: px.x, lat: px.y};
|
||||
},
|
||||
getResolution: function() {
|
||||
return 1;
|
||||
}
|
||||
@@ -164,6 +161,9 @@
|
||||
t.eq(ring.components[0].y, 10, "correct bottom");
|
||||
t.eq(ring.components[2].x, 10, "correct left");
|
||||
t.eq(ring.components[2].y, 15, "correct top");
|
||||
},
|
||||
getLonLatFromViewPortPx: function(px) {
|
||||
return {lon: px.x, lat: px.y};
|
||||
}
|
||||
};
|
||||
var control = {};
|
||||
@@ -190,11 +190,7 @@
|
||||
t.plan(1);
|
||||
|
||||
// setup
|
||||
var map = new OpenLayers.Map("map", {
|
||||
getLonLatFromPixel: function(px) {
|
||||
return {lon: px.x, lat: px.y};
|
||||
}
|
||||
});
|
||||
var map = new OpenLayers.Map("map");
|
||||
|
||||
var control = {"map": map};
|
||||
|
||||
@@ -211,6 +207,17 @@
|
||||
|
||||
var isLeftClick = OpenLayers.Event.isLeftClick;
|
||||
OpenLayers.Event.isLeftClick = function() { return true; };
|
||||
handler.layer = {
|
||||
renderer: {
|
||||
clear: OpenLayers.Function.Void
|
||||
},
|
||||
addFeatures: OpenLayers.Function.Void,
|
||||
drawFeature: OpenLayers.Function.Void,
|
||||
destroyFeatures: OpenLayers.Function.Void,
|
||||
getLonLatFromViewPortPx: function() {
|
||||
return xy;
|
||||
}
|
||||
};
|
||||
|
||||
// test
|
||||
map.events.triggerEvent("mousedown", {"xy": xy});
|
||||
|
||||
Reference in New Issue
Block a user