0
votes

I've posted this in GisStackExchange with no luck.

I have a problem that i think is related with the interaction between OpenLayers and my Google map Base Layer (inconsistencies with coordinates systems, or something like that). Maybe also this could be related with the request that im sending to GeoServer through WMS. But i'm confused.

My setup: Like i said, i have an olMap with a base layer that comes from google. Here is the map init:

function initMap() {

    // World Geodetic System 1984 projection (lon/lat)
    var WGS84 = new OpenLayers.Projection("EPSG:4326");

    // WGS84 Google Mercator projection (meters)
    var WGS84_google_mercator = new OpenLayers.Projection("EPSG:900913");

    var options = {
       projection: WGS84_google_mercator,
       displayProjection: WGS84,
    };


    window.map = new OpenLayers.Map('map_canvas', options);

    var google_default =  new OpenLayers.Layer.Google("Google Default", {wrapDateLine: false, numZoomLevels: 30, sphericalMercator: true})
    var google_satellite = new OpenLayers.Layer.Google("Google Satellite", {type: google.maps.MapTypeId.SATELLITE, wrapDateLine: false})

    map.addLayers([google_default]);


    window.map.zoomTo(2);
    window.map.setCenter(0);

        // build up all controls
    window.map.addControl(new OpenLayers.Control.Zoom());
    window.map.addControl(new OpenLayers.Control.MousePosition())
    window.map.addControl(new OpenLayers.Control.Navigation());
    window.map.addControl(new OpenLayers.Control.LayerSwitcher());

}

When the zoom is small the server send me the response with the feature info, but when zoom in the server no longer responds.

I tried to fix that passing buffer param region to make the intersection in the server side. But i have no good results when zooming even with an excessive value for that:

vendorParams: {
   buffer: 100, // one hundred is an excessive value
}, 

Also i'm printing out the event.xy that is different when zooming but that make sense, isn't it?

An Alert is launched in the beforegetfeatureinfo method of the WMSGetFeatureInfo Control listener:

beforegetfeatureinfo function(event) {
                  // Code here to set the content of queryableMapLayers
                  // The event object will contain xy of mouse click
                  alert(event.xy);
                }

Without zoom i get (1136, 273) values and (600, 304) with large zoom approximately in the same map location. Like i said, i'm confused about the issue. I spend much time googling it but i didn't found any guideline.

Any thoughts?

1

1 Answers

0
votes

I would recommend to use the correct coordinate reference for your map object which is EPSG:3857 (Web Mercator). I also don't think that there are 30 zoom levels to the map. Below is an example map object for the Google satelite base map.

//define map object with base layers
map = new OpenLayers.Map('OpenLayers_canvas', {
    projection: 'EPSG:3857',
    layers:
        [
        new OpenLayers.Layer.Google('Google Satellite', { type: google.maps.MapTypeId.SATELLITE, numZoomLevels: 22 })
        ],
    center: new OpenLayers.LonLat(-99.1638182, 19.3880964).transform('EPSG:4326', 'EPSG:3857'),
    zoom: 10
});