1

I have a strange ZOOM behavior. I am using GeoServer 2.6.1/OpenLayers 2.13.1. I have a layer I created from a MrSid file and am serving as a wms layer.

Lets call it the "problematic" layer. When I serve this "problematic" layer alone, everything is ok. When I serve it with a base layer, I get a strange effect: when I zoom in, the "problematic" layer zooms in, then zooms back out again.

If I click on a check box to hide the "problematic" layer (and only show the base layer which is at correct zoom) and then I click on the check box to show the "problematic" layer again, it aligns correctly with the base layer.

On the GeoServer side, I am "forcing declared" on both the base layer and the "problematic" layer. The Native SRS and the Declared SRS are both set to EPSG:2236. On the OpenLayers side, I am using the displayProjection setting and have it also set to 2236 as recommend in other threads.

What could be the issue?

OpenLayers Code:

var map, baseLayer, problematicLayer;

        // pink tile avoidance
        OpenLayers.IMAGE_RELOAD_ATTEMPTS = 5;
        // make OL compute scale according to WMS spec
        OpenLayers.DOTS_PER_INCH = 25.4 / 0.28;


        function init() {

            // Setup Projection
            epsg2236 = new OpenLayers.Projection("EPSG:2236");

            // Setup Format
            format = 'image/png';

            // Setup Extent
            var bounds = new OpenLayers.Bounds(
                    858665.911628, 516256.950565,
                    870969.136, 527480.405429
                );


            // Setup Map Options
            var options = {
                maxExtent: bounds,
                maxResolution: 128.890625,
                projection: epsg2236,
                displayProjection: epsg2236,
                units: 'm'
            };

            // Setup Map
            map = new OpenLayers.Map('map', options);

            // Setup tiled base layer
            baseLayer = new OpenLayers.Layer.WMS(
                "sf:base_lines - Tiled",
                "http://server01:8085/geoserver/sf/wms",
                {
                    "LAYERS": 'sf:base_lines',
                    "STYLES": '',
                    TRANSPARENT: 'true',
                    format: format
                },
                {
                    visibility: true,
                    buffer: 0,
                    displayOutsideMaxExtent: true,
                    isBaseLayer: true,
                    yx: { 'EPSG:2236': false }
                }
            );

            // The Problematic Layer
            problematicLayer = new OpenLayers.Layer.WMS(
                    "sf:SID_2014 - Tiled",
                    "http://server01:8085/geoserver/sf/wms",
                {
                    "LAYERS": 'sf:SID_2014',
                    "STYLES": '',
                    TRANSPARENT: 'true',
                    format: format
                },
                {
                    visibility: false,
                    buffer: 0,
                    displayOutsideMaxExtent: true,
                    isBaseLayer: true,
                    yx: { 'EPSG:2236': false }
                }
            );


 map.addLayers([baseLayer, problematicLayer]);


// Add MousePosition Control
            map.addControl(new OpenLayers.Control.MousePosition());

            // Zoom to Max Extent
            if (!map.getCenter()) {
                map.zoomToMaxExtent();
            }
 } 

Update #1

I just uploaded a video of the issue so you can get an exact idea of what I mean by "zooms in and then out again":

https://vimeo.com/119384955

1 Answer 1

1

Fixed the problem myself. The "temporary" fix is to hide/show the layer before every zoom:

// Zoom Changed event
map.events.register("zoomend", map, zoomChanged);

function zoomChanged()
{

    // Hide MrSid  layer (There is a bug when changing zooms, the workaround is to 
    // hide/show layer, if not MrSid layer does not work)
    problematicLayer.setVisibility(false);
    // Show MrSid layer
    problematicLayer.setVisibility(true);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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