New private movePyPx method to avoid going through all the unnecessary pixel-lonlat conversions. p=elemoine,me (closes #3062)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@11535 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -1323,7 +1323,7 @@
|
||||
var m = {
|
||||
'baseLayer': { 'units': {} },
|
||||
'getSize': function() { return {'w': 10, 'h': 15}; },
|
||||
'getCenter': function() { return {'lon': -5, 'lat': -25}; },
|
||||
'getCachedCenter': function() { return {'lon': -5, 'lat': -25}; },
|
||||
'zoomToExtent': function(extent, closest) {
|
||||
t.ok(extent.equals(g_ExpectedExtent), "extent correctly calculated for zoomToExtent()");
|
||||
t.ok(closest == g_Closest, "closest correctly passed on to zoomToExtent()");
|
||||
@@ -1701,6 +1701,41 @@
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
function test_moveByPx(t) {
|
||||
t.plan(8);
|
||||
|
||||
var map = new OpenLayers.Map({
|
||||
div: 'map',
|
||||
maxExtent: new OpenLayers.Bounds(-50, -50, 50, 50),
|
||||
restrictedExtent: new OpenLayers.Bounds(-10, -10, 10, 10),
|
||||
layers: [
|
||||
new OpenLayers.Layer('name', {isBaseLayer: true})
|
||||
]
|
||||
});
|
||||
map.zoomToExtent(new OpenLayers.Bounds(-1, -1, 1, 1));
|
||||
|
||||
// check initial state
|
||||
t.eq(map.layerContainerDiv.style.left, '0px', 'layer container left correct');
|
||||
t.eq(map.layerContainerDiv.style.top, '0px', 'layer container top correct');
|
||||
|
||||
// move to a valid position
|
||||
map.moveByPx(-455, 455);
|
||||
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
|
||||
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
|
||||
|
||||
// move outside the max extent
|
||||
map.moveByPx(-4500, 4500);
|
||||
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
|
||||
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
|
||||
|
||||
// move outside the restricted extent
|
||||
map.moveByPx(-500, 500);
|
||||
t.eq(map.layerContainerDiv.style.left, '455px', 'layer container left correct');
|
||||
t.eq(map.layerContainerDiv.style.top, '-455px', 'layer container top correct');
|
||||
|
||||
map.destroy();
|
||||
}
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
Reference in New Issue
Block a user