[OpenLayers-Users] suppress controls?

Erik Uzureau euzuro at gmail.com
Thu Oct 19 00:13:32 EDT 2006


Hi John,

> I'm trying to create a simple map w/ OpenLayers.Layer.WMS.  It's not clear
> to me how:
> 1) to suppress the pan/zoom controls

pass an empty array as the 'controls' option to map.

I have now added this to the FAQ:
http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#Controls

> 2) to specify the image size
set the style height/width on your map div

> and bbox

instead of setCenter, call zoomToExent()


Example of 500x300 div zoomed to bl(-10,-15) ur(10,15):



<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <style type="text/css">
        #map {
            width: 500px;
            height: 300px;
            border: 1px solid black;
        }
    </style>
    <script src="../lib/OpenLayers.js"></script>
    <script type="text/javascript">
        <!--
        var map, layer;

        function init(){
            map = new OpenLayers.Map( $('map'), {controls: [] } );
            layer = new OpenLayers.Layer.WMS( "OpenLayers WMS",
                    "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
            map.addLayer(layer);

            map.zoomToExtent(new OpenLayers.Bounds(-10,-15,10,15));
        }

        // -->
    </script>
  </head>
  <body onload="init()">
    <div id="map"></div>
  </body>
</html>

Hope that helps!
--Erik



More information about the Users mailing list