Hi all,<br><br>I am working from the Image Layer Example:<br><a href="http://openlayers.org/dev/examples/image-layer.html">http://openlayers.org/dev/examples/image-layer.html</a><br><br>Goal is to switch to an image layer showing a picture (e.g. of a Church).<br>
I managed to switch from the original map to the image layer using map.setBaseLayer(image-layer);<br>
<br>Problem is how to calculate OpenLayers.Bounds?<br>Simply replacing<br> new OpenLayers.Bounds(-180, -88.759, 180, 88.759),<br>by<br> new OpenLayers.Bounds(-20037508, -20037508, 20037508, 20037508.34)<br>did not work.<br>
(It just blows up a single pixel to cover the whole map-div.)<br><br>And even when the example states:<br>..."If you construct it without any resolution related options [Does this mean Bounds???],
the layer will be given a single resolution based on the extent/size."...<br>Commenting out the "new OpenLayers.Bounds( ..." line does not work, it just gives an error in both OL 2.7 and 2.8:<br>
<pre id="line13">this.extent.getHeight is not a function<br><a href="http://localhost/js/OpenLayers.js">http://localhost/js/OpenLayers.js</a><br>Line 1187<br><br>So how to calculate OpenLayers.Bounds to display the image at its original 100% size? <br>
Or to fit in the map-div?<br><br>Thanks,<br>Jan<br><br><br>Image Layer Example Code (Cleaned up a bit): <br></pre><pre id="line13"><<span class="start-tag">script</span><span class="attribute-name"> type</span>=<span class="attribute-value">"text/javascript"</span>><br>
var map;<br> function init(){<br> map = new OpenLayers.Map('map');<br><br> var options = {numZoomLevels: 3};<br><br> var graphic = new OpenLayers.Layer.Image(<br> 'City Lights',<br>
'<a href="http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif">http://earthtrends.wri.org/images/maps/4_m_citylights_lg.gif</a>',<br> new OpenLayers.Bounds(-180, -88.759, 180, 88.759),<br>
new OpenLayers.Size(580, 288),<br> options<br> );<br> <br> var jpl_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",<br> "<a href="http://t1.hypercube.telascience.org/cgi-bin/landsat7">http://t1.hypercube.telascience.org/cgi-bin/landsat7</a>", <br>
{layers: "landsat7"}, options);<br><br> map.addLayers([graphic, jpl_wms]);<br> map.addControl(new OpenLayers.Control.LayerSwitcher());<br> map.zoomToMaxExtent();<br>
}<br> </<span class="end-tag">script</span>><br></pre>