Thursday 26 December 2019

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


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 = result.data.map.mapBounds;

    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 = result.data.map.mapBounds;

    var x1 = parseFloat( bounds.x1 );
    var x2 = parseFloat( bounds.x2 );
    var y1 = parseFloat( bounds.y1 );
    var y2 = parseFloat( bounds.y2 );

    function wmsLoaded() {
    map.redraw(true);

    }

    //
    // @param { } 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 https://github.com/openlayers/openlayers/issues/573




No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...