Ticket #1448 (closed bug: fixed)
zoomToScale does not exactly zoom to the given scale
| Reported by: | bartvde | Owned by: | |
|---|---|---|---|
| Priority: | major | Milestone: | 2.8 Release |
| Component: | Map | Version: | 2.5 |
| Keywords: | Cc: | ||
| State: |
Description
You can try the following example to reproduce. zoomToScale 1:100000 will actually zoom to 1:250000.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="stylesheet" href="../theme/default/style.css" type="text/css" />
<style type="text/css">
#map {
width: 512px;
height: 512px;
border: 1px solid black;
}
</style>
<script src="../lib/OpenLayers.js"></script>
<script type="text/javascript">
var lon = 5;
var lat = 40;
var zoom = 5;
var map, layer;
function init(){
map = new OpenLayers.Map( 'map', { 'controls': [], fractionalZoom: true, 'projection': 'EPSG:28992', 'units':'m',
'maxExtent': new OpenLayers.Bounds(-200000,0,600000,900000),
'scales': [10000000, 5000000, 2000000, 1500000, 1000000, 750000, 500000, 375000, 250000, 100000, 50000,
25000, 10000, 5000, 2500, 1000, 500, 100]});
var graphic = new OpenLayers.Layer.Image('Dummy', '../img/blank.gif', new OpenLayers.Bounds(0,300000,300000,600000),
map.getSize(), {isBaseLayer: true, displayInLayerSwitcher: false});
map.addLayer(graphic);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.Scale());
map.zoomToScale(100000);
alert(map.getScale());
}
</script>
</head>
<body onload="init()">
<div id="map"></div>
</body>
</html>
Attachments
Change History
Note: See
TracTickets for help on using
tickets.

