[OpenLayers-Users] WMS overlay disappearing with Google Maps v.3

Gery . gamejihou at hotmail.com
Sun Apr 21 14:20:43 PDT 2013


Hi Dalton,

In my case, google3 and OL 2.11 work with all zooms. I serve my WMS with mapserver and also use the maxResolution/etc... similar to as explained here: http://lists.osgeo.org/pipermail/openlayers-users/2011-May/020537.html

BTW, are you correctly using your projections? I mean, 900913 was set in EPSG file of proj? You're using maxExtent in degrees, that seems wrong to me, because all should be in utm.

Cheers,

Gery

Sent from my iBath

On Apr 21, 2013, at 22:15, "Dalton Filho" <daltonfilho at gmail.com> wrote:

Hello Gery,

Thank you for your help. I'm using version 2.12. I removed the redundant setBaseLayer(gsat)line but the WMS overlay still fails to appear unless I zoom out twice. I did the same test using version 2.11 but results are identical. After I zoom in to a certain zoom level the overlay simply disappears whereas in the Google Maps v.2 test they did show at that same zoom level.

I compared the stack trace of zoom-in requests that rendered the overlay with the stack trace of requests that did not render it. The point where it fails is the method Tile.shouldDraw(). It is returning false for the zoom-in requests for which the overlay was not rendered. This method returns true when the overlays are rendered. This is the method in question:

    shouldDraw: function() { 
        var withinMaxExtent = false,
            maxExtent = this.layer.maxExtent;



        if (maxExtent) {
            var map = this.layer.map;
            var worldBounds = map.baseLayer.wrapDateLine && map.getMaxExtent();
            if (this.bounds.intersectsBounds(maxExtent, {inclusive: false, worldBounds: worldBounds})) {
                withinMaxExtent = true;
            }
        }



        return withinMaxExtent || this.layer.displayOutsideMaxExtent;
    },  

I captured the value of the worldBounds, this.bounds and maxExtent variables inside it to create a test that anyone can reproduce:


// Test #1: values captured in a zoom request for which the WMS overlay was NOT rendered
function test1() {
    var bounds = new OpenLayers.Bounds(-3785006.7128486, 2429373.3721214, 3729058.9146514, 8064922.5927464);
    var maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
    var worldBounds = new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
    
    if (bounds.intersectsBounds(maxExtent, {inclusive: false, worldBounds: worldBounds})) {
        return "Intersected";
    } 
 
    return "Not intersected";
}

//Example #2: values captured in a zoom request for which the WMS overlay did render
function test2() {
    var bounds = new OpenLayers.Bounds(-7776854.077458, -677027.4569557, 7251277.177542, 10594070.984294);
    var maxExtent = new OpenLayers.Bounds(-180, -90, 180, 90);
    var worldBounds = new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
    
    if (bounds.intersectsBounds(maxExtent, {inclusive: false, worldBounds: worldBounds})) {
        return "Intersected";
    } 
 
    return "Not intersected";
}


Does anyone in the community knows why the first test does not intersect?

- Is the Bounds.intersectsBounds() implementation incorrect?
- Are any of these values inside the function invalid or absurd? If so, why?

In the meanwhile the only thing I can do is to skip the shouldDraw() verification and force draw = true inside Tile.draw(). A dirty hack to keep me afloat...


Best regards,

Dalton

On Sat, Apr 20, 2013 at 1:32 PM, Gery . <gamejihou at hotmail.com> wrote:
> Hi Dalton,
> 
> Are you using OL 2.12 or 2.11? I don't think you need
> setBaseLayer(gsat);
> because you already set that. I use google3 and 2.11 and it works perfect without that.
> 
> HTH,
> 
> Cheers,
> 
> Gery
> 
> 
> Sent from my iBath
> 
> On Apr 20, 2013, at 17:56, "Dalton Filho" <daltonfilho at gmail.com> wrote:
> 
> Hello list,
> 
> I created a map with Google layers as base layers + a WMS overlay layer. Unfortunately the WMS overlay disappears when zooming in. In fact, you can only start seeing the WMS overlay after you zoom out twice.
> 
> In another test I created a map with Google Maps v.2 base layers + the *same* WMS overlay layer I used in the first test. This time the WMS overlay shows in all zoom levels.
> 
> I have attached 4 files that reproduce the error (you should edit the openlayers inclusion or paste them under the examples directory)
> 
> Has anyone had the same issue?
> 
> Best regards,
> 
> Dalton
> <google-v2-test.html>
> <google-v2-test.js>
> <google-v3-test.html>
> <google-v3-test.js>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130421/141cb8df/attachment-0001.html>


More information about the Users mailing list