Hi Greg, I think you are missing some some basic concepts. When you specify the maxExtent, this is the geographic extent of the map, not the size of the image in pixels. Please bear with me as I explain what it is that OpenLayers does and then I will try to answer your questions more directly, but I think some context might help.
In the default tiled mode, OpenLayers creates small images (256x256) referred to as tiles and orients those tiles in the user interface to represent part of the geographic extent the user is viewing. The specific layer type(s) that you use translate the image and its geographic extent into an appropriate request for the type of layer. This results in a number of partial maps that are visually stitched together to create a (hopefully) seamless view of the map. OpenLayers needs a couple of things to be able to make the necessary calculations. First, it needs to know what the maximum geographic extent of your data is, the projection/units of the map, and the resolutions (in map units per pixel) that you want to display your map at. By default, OpenLayers assumes that your map projection is EPSG: 4326 [1] with units of decimal degrees and a maximum extent of -180, -90, 180, 90 (the whole world in latitude and longitude). The default maximum resolution is designed to fit the whole world into one 256x256 tile and the value is 360/256 = 1.40625. The default number of zoom levels is 16, and OpenLayers (again by default) divides the default maximum resolution (1.40625) progressively by 2 to calculate the resolution at each of those zoom levels. When you create a new map based on these default parameters, it should start at the maximum resolution and decide that it needs only 1 tile to represent your maximum extent at that resolution. As you zoom in (either programmatically or interactively), OpenLayers determines the appropriate resolution from the ones that it has calculated and figures out how many tiles it would need to represent the current geographic extent that the user is looking at on the screen (plus a small offscreen buffer) at that resolution. It then creates (or reuses) the right number of tile images and the specific layer type (MapServer in this case) takes the parameters for the tile (pixel size and geographic size) and makes a request to MapServer to generate the correct map image. On to your specific questions. 1) OpenLayers assumes by default that the map is in the EPSG:4326 projection with maximum extent -180,-90,180,90 and units of decimal degrees. Setting a maximum extent of 0, 0, 300000, 700000 is not valid in this projection and things will not work as you expect. If that is actually the geographic extent of your data, then you also need to set the appropriate projection and units. If that is the maximum size in pixels that you want the map to be, then you probably need to calculate a minResolution value. OpenLayers assumes a vertical axis that is positive-up. If you want to change this, you need to override the calculateGridLayout method. Note that MapServer also assumes positive-up I think so I'm not sure how this would help you. For 2), you only need one layer - when you zoom in and out, OpenLayers sends requests at the appropriate resolution. You need to determine what the maximum (or minimum) resolution is for your application and pass numZoomLevels: 5 (OpenLayers defaults to 16). For 3), those are mapserver cgi specific parameters, review the mapserver documentation for CGI mode (http://mapserver.gis.umn.edu/docs/reference/cgi ). As explained above, OpenLayers will by default use 256x256 images for tiles and calculate the appropriate geographic extent for each of those images from the resolution of the current view. If you just want to display an image, you can also use the Image layer class and not bother with MapServer. Perhaps if you explained a bit more about your use case it would help us help you further? Cheers Paul [1] http://en.wikipedia.org/wiki/European_Petroleum_Survey_Group On 4-Oct-08, at 2:48 PM, Greg Donald wrote: > I've been learning the Openlayers API for several days now and have > some questions I can't seem to find answers for in the mailing list > archives. > > > 1) How can I construct bounds that only have positive numbers? When I > try this bit of code I still get negative numbers in my tile requests: > > maxExtent: new OpenLayers.Bounds( 0, 0, 300000, 7000000 ) > > Is it possible to make a grid that works top-down, left to right, 0 up > to whatever, both horizontally and vertically? > > 0 1 2 3 > 1 > 2 > 3 > > > 2) I want to create 5 different depths of data display. Do I need to > construct 5 individual layers or is one layer sufficient since I plan > to request tiles based on coordinates? I don't see any sort of > "layer" variable arriving in my tile request variables. > > layer = new OpenLayers.Layer.MapServer( "Level 1", "/image/", {}, > {} ); > > http://dev.openlayers.org/releases/OpenLayers-2.6/doc/apidocs/files/OpenLayers/Layer/MapServer-js.html > > I've read the above URL, but where can I find api documentation for > the last two constructor parameters? Is this possibly where I would > define the "layer" I'm requesting as far the tile requests? > > > 3) Where can I find documenation for these tile request variables? > > {"imgy"=>"128", "map_imagetype"=>"png", "imgext"=>"-1680 1000 -1320 > 1360", "mode"=>"map", "imgxy"=>"256 256", "map_size"=>"256 256", > "mapext"=>"-1680 1000 -1320 1360", "imgx"=>"128"} > > Looking at the "imgext" request variable, is -1680,1000 the bottom > left and -1320,1360 the top right? How does this corelate to a > 256x256 tile size? > > What's the difference between "imgext" and "mapext"? They always seem > to be the same. > > Why isn't map_size "300000 7000000" like I defined it above? > > > Here's my code so far: > > <script type="text/javascript"> > var lon = 0; > var lat = 0; > var zoom = 1; > var map, layer; > function init() > { > var options = { > numZoomLevels: 1, > maxExtent: new OpenLayers.Bounds( 0, 0, 300000, 7000000 ), > }; > map = new OpenLayers.Map( 'map', options ); > > layer = new OpenLayers.Layer.MapServer( "Level 1", "/image/", {} ); > map.addLayer( layer ); > > map.setCenter( new OpenLayers.LonLat( lon, lat ), zoom ); > map.removeControl( map.controls[ 1 ] ); > map.addControl( new OpenLayers.Control.LayerSwitcher() ); > map.addControl( new OpenLayers.Control.PanZoomBar() ); > map.addControl( new OpenLayers.Control.MousePosition() ); > map.addControl( new OpenLayers.Control.OverviewMap() ); > map.addControl( new OpenLayers.Control.KeyboardDefaults() ); > } > </script> > <div id="map"></div> > > > > Thanks, > > > -- > Greg Donald > http://destiney.com/ > _______________________________________________ > Users mailing list > [email protected] > http://openlayers.org/mailman/listinfo/users _______________________________________________ Users mailing list [email protected] http://openlayers.org/mailman/listinfo/users
