[OpenLayers-Users] Map won't center

Lawrence Miller lawrence.miller at noaa.gov
Thu Feb 9 20:37:22 EST 2012


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">
        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>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20120209/060358db/attachment.html


More information about the Users mailing list