[OpenLayers-Users] Map won't center

Lawrence Miller lawrence.miller at noaa.gov
Mon Feb 13 12:58:27 EST 2012


I get the same effect  when I load the script as in the examples.

     <script src="http://openlayers.org/api/OpenLayers.js"></script>
      <script type="text/javascript">
        var map;
        function init (){
        var options = {
            maxExtent: new OpenLayers.Bounds(0,0,1410,913),
            maxResolution: "auto"...

      </script>
    </head>
    <body onload="init()" >
      <h1 id="title">AAWU Product Layering Test</h1>
      <div style="width:696px; height: 425px; border: 1px solid;"
id="map"></div>
    </body>





On Sun, Feb 12, 2012 at 8:29 PM, Eric Lemoine
<eric.lemoine at camptocamp.com>wrote:

>
>
> On Friday, February 10, 2012, Lawrence Miller <lawrence.miller at noaa.gov>
> wrote:
> > I am trying to load a basemap and layers into a 696x425 frame. The map
> won't appear in the center of the frame, it appears centered low and to the
> left. I can drag the map into the correct location, but I would prefer it
> just appear there. Any suggestions?
> >
> > my script:
> >       <div style="width:696px; height: 425px; border: 1px solid;"
> id="map"></div>
> >       <script defer="defer" type="text/javascript">
>
> What if you create the map in an onload callback function as in the
> OpenLayers examples?
>
>
>
> >         var options = {
> >             maxExtent: new OpenLayers.Bounds(0,0,1410,913),
> >             maxResolution: "auto"
> >         };
> >         var map = new OpenLayers.Map('map',options);
> >         var base = new OpenLayers.Layer.Image("Basemap",
> >              "newestbasemap.gif",
> >              new OpenLayers.Bounds(0,0,1410,913),
> >              new OpenLayers.Size(1410,913),
> >              {isBaseLayer: true}
> >              );
> >         var ice = new OpenLayers.Layer.Image("Freezing Level",
> >              "pt3.gif",
> >              new OpenLayers.Bounds(0,0,1410,913),
> >              new OpenLayers.Size(1410,913),
> >               {isBaseLayer: false,
> >                visibility: false,
> >                opacity: 0.80}
> >              );
> >         var wind = new OpenLayers.Layer.Image("Wind Speed",
> >              "pt3windspd.gif",
> >              new OpenLayers.Bounds(0,0,1410,913),
> >              new OpenLayers.Size(1410,913),
> >               {isBaseLayer: false,
> >                visibility: false,
> >                opacity: 0.60}
> >              );
> >         var turb = new OpenLayers.Layer.Image("Turbulence",
> >              "pt3turb.gif",
> >              new OpenLayers.Bounds(0,0,1410,913),
> >              new OpenLayers.Size(1410,913),
> >               {isBaseLayer: false,
> >                visibility: false,
> >                opacity: 0.60}
> >              );
> >         map.addLayers([base, ice, wind, turb]);
> >         map.setCenter(new OpenLayers.LonLat(705,456));
> >         map.zoomToMaxExtent();
> >         map.addControl(new OpenLayers.Control.LayerSwitcher());
> >       </script>
>
> --
> Eric Lemoine
>
> Camptocamp France SAS
> Savoie Technolac, BP 352
> 73377 Le Bourget du Lac, Cedex
>
> Tel : 00 33 4 79 44 44 96
> Mail : eric.lemoine at camptocamp.com
> http://www.camptocamp.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120213/6073b163/attachment.html


More information about the Users mailing list