Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am seeing one weird thing in Openlayers today. I am unable to see whole map by using panzoombar, previously i used to.

<html>
<head>
  <title>OpenLayers Example</title>
    <script src="http://openlayers.org/api/OpenLayers.js"></script>
    </head>
    <body>
      <div style="width:100%; height:100%" id="map"></div>
      <script defer="defer" type="text/javascript">
       var  Geographic  = new OpenLayers.Projection("EPSG:4326"); 
       var  Mercator = new OpenLayers.Projection("EPSG:900913");

       var map = new OpenLayers.Map({
           div: "map",
           projection: Mercator,
           displayProjection: Geographic,
           center: new OpenLayers.LonLat(0, 0),
           minResolution: "auto",
           minExtent: new OpenLayers.Bounds(-1, -1, 1, 1),
           maxResolution: "auto",
           maxExtent: new OpenLayers.Bounds(-180, -90, 180, 90),
           units : 'km'

       });

       var layerOSM = new OpenLayers.Layer.OSM();
       map.addLayer(layerOSM);
       map.addControl(new OpenLayers.Control.LayerSwitcher());
       map.setCenter(new OpenLayers.LonLat(0, 0), 1);
       map.addControl(new OpenLayers.Control.PanZoomBar());

      </script>

</body>
</html>

this is the code, panzoombar is showing all the levels, but it stopped at last above two levels and not coming down.

share|improve this question
    
Whats the problem. Is it the Openlayers problem? –  Ramesh Kotha Jul 17 '12 at 23:00
    
Does this happen in other browsers? Is your browser zoomed in too far? Try pressing ctrl+0 –  Geoist Jul 19 '12 at 8:56
    
Yes it is happening in all browsers –  Ramesh Kotha Jul 19 '12 at 12:33

1 Answer 1

up vote 1 down vote accepted
+50

i think this is all about div size. openlayers automatically makes its minimum zoom level to fit it to whole world map... and this does not seem as a problem.

it makes people that "you can see the whole world at this zoom level and i dont want you to see blank images with decreasing the level of zoom."

when width and height is 100% or 600px,400px:

it makes automatically min zoom level to : 3

openlayers

when width: 200px and height: 400px :

it makes automatically min zoom level to : 1

enter image description here

you can test it with changing the div width and height...

i hope it helps you...

share|improve this answer
    
Thank you very much @Aragon, But i want to show the map with width 100% and height 100%. How can i do it. –  Ramesh Kotha Jul 19 '12 at 8:23
    
this is not a problem if you think so use OpenLayers 2.10 library. dev.openlayers.org/releases/OpenLayers-2.10/lib/OpenLayers.js Dont forget to add missing libraries as OpenLayers.Projection. if not you can get OpenLayers.X is not a constructor... –  Aragon Jul 19 '12 at 8:26
    
the url is broken? –  Ramesh Kotha Jul 19 '12 at 8:27
    
ok i have fixed the missing url link... –  Aragon Jul 19 '12 at 8:31
    
thanks you very much... –  Ramesh Kotha Jul 19 '12 at 8:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.