[OpenLayers-Users] updateSize on div resize

Christian López Espínola penyaskito at gmail.com
Sat Jun 9 12:21:21 EDT 2007


Hi Kevin,

I wrote a little test and works fine for me in FF2.0, Opera9.2 and
IE7. The overview map updates his position to the bottom right corner
of the map.

Maybe we can help you if you submit a piece of code.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Overview Map Example</title>
<script src="../lib/OpenLayers.js" type="text/javascript"></script>
<style>
#map{
    width:100%;
    height:500px;
    border:1px solid;
}
</style>
</head>
<body>
  <div id="map"></div>
  <script defer="defer" type="text/javascript">
    var map = new OpenLayers.Map('map');
    // my city
    var constantina = new OpenLayers.LonLat(-5.6165,37.8623);
    var wms = new OpenLayers.Layer.WMS( "OpenLayers WMS",
        "http://labs.metacarta.com/wms/vmap0", {layers: 'basic'} );
    var nasa_wms = new OpenLayers.Layer.WMS( "NASA Global Mosaic",
        "http://wms.jpl.nasa.gov/wms.cgi", {layers: "modis,global_mosaic"} );

    map.addLayers([
        nasa_wms,
        wms
    ]);

    map.addControl(new OpenLayers.Control.LayerSwitcher());

    var options = {
      layers: [wms.clone()],
      minRatio: 8,
      maxRatio: 128
    };
    var overview = new OpenLayers.Control.OverviewMap(options);

    map.addControl(overview);

    map.setCenter(constantina, 4);

    overview.maximizeControl();
	
	var w=600;
  </script>
  <script>
  function mini(){
	w = "70%";
	map.div.style.width = w;
	map.updateSize();
  }
  </script>
  <input type="button" onclick="mini();return false;" value="Hacer mas xico"/>
</body>
</html>



On 6/9/07, Kevin Kempfer <mail at kevinkempfer.de> wrote:
> Hi Christian,
>
> > The position of the OverviewMap is set as absolute on the style.css.
> > Maybe you can change the right property of his dom element.
>
> As the OverviewMap is generated automatically, I later don't know its
> DOM-ID. Maybe there's a way to access it through the openlayers
> hierarchy? If I could manage to access the DOM-Element of the
> OverviewMap, there's is of course no problem in changing its
> right-property. But I think in general map.updateSize() should give the
> information down to the controls as it does to the layers.
>
> Regards,
>
> Kevin
>
>


-- 
Regards,

Christian López Espínola


More information about the Users mailing list