Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can we request new OpenLayers WMS image for an extent without moving the map center ?

Reading OpenLayers code, OpenLayers move map center to new extent, and THEN do HTTP request to get the image.

Is it possible to instruct the map to HTTP load certain extent and when 'tileloaded' is fired, THEN load new WMS image?

Edit ----------------------

  1. The problem is I need to "tell the map to zoomToExtent" so it gets a new bound.

  2. OpenLayers Map sets its center and zoom first, and then request new map through HTTP.

  3. The map response will be available in 2 seconds, until that time, map view is blank (if new bound is outside current bound).

    if( result.zoom ) {

                           var bounds =;
                            var x1 = parseFloat( bounds.x1 );
                            var x2 = parseFloat( bounds.x2 );
                            var y1 = parseFloat( bounds.y1 );
                            var y2 = parseFloat( bounds.y2 );
                            map.zoomToExtent([x1, y1, x2, y2]);
  4. What i think i need is fetchWmsBound() below.

         if( result.zoom ) {
                           var bounds =;
                            var x1 = parseFloat( bounds.x1 );
                            var x2 = parseFloat( bounds.x2 );
                            var y1 = parseFloat( bounds.y1 );
                            var y2 = parseFloat( bounds.y2 );
                            function wmsLoaded() {
                            // @param { <Array.number> } bounds,
                            // @param { Function } callback to exec when wms is fetched
                            // fetchWmsBound might trigger a 'fetched' event also
                            map.wmslayer.fetchWmsBound( [x1, y1, x2, y2], wmsLoaded );                                

Filed at

share|improve this question

when u check out OpenLayers.Layer.WMS structure, you can see that it inherits from OpenLayers.Layer.Grid... and when looking at api, you can notice that spiralTileLoad() may help you about what you want...

from OpenLayers doc:

spiralTileLoad: function()

Starts at the top right corner of the grid and proceeds in a spiral towards the center, adding tiles one at a time to the beginning of a queue.

Once all the grid’s tiles have been added to the queue, we go back and iterate through the queue (thus reversing the spiral order from outside-in to inside-out), calling draw() on each tile.


var wms = new OpenLayers.Layer.WMS("NASA Global Mosaic",
          {layers: "modis,global_mosaic"});



i hope it helps you...

share|improve this answer
thanks 4 ur advice, i updated problem description with fetchWmsBound(), which i think i need, but don't know to implement it (yet). – portoalet Jul 4 '12 at 1:15

or maybe you can just do the wms.redraw() function to do this?

share|improve this answer
i've to zoom to new extent first...see edited problem description. – portoalet Jul 4 '12 at 1:16

The map is blanked because applyBackBuffer(),

my workaround is to modify OpenLayers Layer/Grid.js

Pull request

moveTo:function(bounds, zoomChanged, dragging) {
        if (this.singleTile) {

            if ( forceReTile ||
                 (!dragging && !tilesBounds.containsBounds(bounds))) {

                if(zoomChanged && this.transitionEffect !== 'resize') {
                if( this.transitionEffect === 'resize' ) {

                        // if new-bounds is within old-bounds (zoom-out)
                        if( (tilesBounds && tilesBounds.containsBounds(bounds))

                            // if old-bounds intersects new-bounds (pan)
                            || (tilesBounds && tilesBounds.intersectsBounds(bounds))

                            // if old-bounds is within new-bounds (zoom-in)
                            || (bounds && tilesBounds
                                && bounds.containsBounds(tilesBounds)) )

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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