1

I'm using openlayers to overlay a raster. When I zoom out, the overlaid layer expands to cover a larger area than was originally requested. I want the tile to be fixed to a particular boundary, and for the WMS query to end, once the zoom changes. When I get the WMS layer the first time, it looks like this:

enter image description here

However, if I zoom out the screen then looks like this:

enter image description here

My javascript is as follows:

wms_url = 'mysite.com/mapserv.cgi?map=population.map&ny_pop';

oldRaster = new OpenLayers.Layer.WMS( 
               "pop_raster",
               wms_url, 
               {    layers: wms_layer, 
                    transparent: true
                    },
               {    maxExtent: polyBounds, 
                    displayOutsideMaxExtent: false,
                    tileSize: new OpenLayers.Size(tileWidth, tileHeight),                   
                    opacity: 0.3, 
                    gutter: 0
                    }   
           );
           map.addLayer(oldRaster);

I've tried adding the attribute persist: false but it does not change anything. I calculate polyBounds using the screen size, and then tileHeight and tileWidth based on the screen resolution so that one tile fills the box that is drawn on-screen.

When I inspect the GET command using HTTPFox the page seems to be actively pulling down more data from the WMS, but I'm not sure why as there are no fresh requests.

1 Answer 1

1

Try appending this to wms_url : &BBOX=-97.105,24.913,78.794,36.358 but replace the values in this order: minimum longitude, minimum latitude, maximum longitude, maximum latitude.

Make sure the Bounding Box area overlaps with the BoundingBox advertised in the Capabilities XML for the requested geodata object.

Your not using a BBox Strategy anywhere else in your code? This would cause it to make new calls to the server.

7
  • hmm. Thanks for the suggestion. I tried that but am now just getting a blank tile. My wms_url is: http://site.com/mapserv.cgi?map=population.map& new_york_pop&BBOX=-8239644,4974211,-8230593,4979952& I tried both with and without the & at the end.
    – djq
    Apr 11, 2012 at 17:49
  • Thanks can you give me the values for polyBounds and wms_layer so i can test?
    – CaptDragon
    Apr 11, 2012 at 17:56
  • Thanks CaptDragon - here they are: Polybounds (left, right, bottom, top): -8239644 -8230593 4974211 4979952, wms_url: http://urbmet.webfactional.com/mapserv.cgi?map=population.map&, wms_layer: new_york_pop
    – djq
    Apr 11, 2012 at 18:06
  • Strange thing is if you make the tiles really small like: tileSize:new OpenLayers.Size(10,10), then it will work but it takes for ever to load. If you increase the size it increases the size of the bounds error margin.
    – CaptDragon
    Apr 11, 2012 at 19:11
  • hmmm. I was wondering whether it could also be explained by openlayers using GET instead of POST. Not sure I know enough to change how openlayers is handling all of this but it seems like there might be some way of killing the command from remaining alive.
    – djq
    Apr 11, 2012 at 19:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.