<div dir="ltr">Hi Stephen,<div><br></div><div style>thanks for your quick reply, im actually using Drupal Openlayer module but i've got the options with which the map is created, the code:</div><div style><br></div><div style>
...</div><div style><br></div><div style><div>// Initialize openlayers map</div><div>            var openlayers = new OpenLayers.Map(<a href="http://map.id">map.id</a>, options);</div><div>            alert("The map: "+<a href="http://map.id">map.id</a>+" options are: "+JSON.stringify(options, null, 4));</div>
<div><br></div><div>            // Run the layer addition first</div><div>            Drupal.openlayers.addLayers(map, openlayers);</div><div><br></div><div>            // Attach data to map DOM object</div><div>            $(this).data('openlayers', {'map': map, 'openlayers': openlayers});</div>
<div><br></div><div>            // Finally, attach behaviors</div><div>            Drupal.attachBehaviors(this);</div><div><br></div><div>...</div></div><div style><br></div><div style>The output:</div><div style><div><br>
</div><div>The map: openlayers-map-a47c4de7 options are: {</div><div>    "projection": {</div><div>        "projCode": "EPSG:900913"</div><div>    },</div><div>    "displayProjection": {</div>
<div>        "projCode": "EPSG:4326"</div><div>    },</div><div>    "maxExtent": {</div><div>        "left": -20037508.34,</div><div>        "bottom": -20037508.34,</div><div>
        "right": 20037508.34,</div><div>        "top": 20037508.34</div><div>    },</div><div>    "units": "m",</div><div>    "maxResolution": "auto",</div><div>
    "controls": [],</div><div>    "theme": "/sites/all/modules/openlayers/themes/default_dark/style.css"</div><div>}</div><div><br></div><div style>Here is how drupal adds the layers:</div><div style>
<br></div><div style><div>'addLayers': function(map, openlayers) {</div><div><br></div><div>    var sorted = [];</div><div>    for (var name in map.layers) {</div><div>      sorted.push({'name': name, 'weight': map.layers[name].weight, 'baselayer': map.layers[name].baselayer });</div>
<div>    }</div><div><br></div><div>    sorted.sort(function(a, b) {</div><div>      var x = parseInt(a.weight, 10), y = parseInt(b.weight, 10);</div><div>      return ((a.baselayer && x < y) ? -1 : ((b.baselayer || x > y) ? 1 : 0));</div>
<div>    });</div><div><br></div><div>    for (var i = 0; i < sorted.length; ++i) {</div><div>      var layer,</div><div>        name = sorted[i].name,</div><div>        options = map.layers[name];</div><div><br></div>
<div>      // Add reference to our layer ID</div><div>      options.drupalID = name;</div><div>      // Ensure that the layer handler is available</div><div>      if (options.layer_handler !== undefined &&</div><div>
        Drupal.openlayers.layer[options.layer_handler] !== undefined) {</div><div>        var layer = Drupal.openlayers.layer[options.layer_handler](map.layers[name].title, map, options);</div><div><br></div><div>        layer.visibility = !!(!map.layer_activated || map.layer_activated[name]);</div>
<div><br></div><div>        if (layer.isBaseLayer === false) {</div><div>          layer.displayInLayerSwitcher = (!map.layer_switcher || map.layer_switcher[name]);</div><div>        }</div><div><br></div><div>        if (map.center.wrapdateline === '1') {</div>
<div>          // TODO: move into layer specific settings</div><div>          layer.wrapDateLine = true;</div><div>        }</div><div><br></div><div>        alert("The layer is "+JSON.stringify(map.layers, null, 4));</div>
<div>        openlayers.addLayer(layer);</div><div>      }</div><div>    }</div></div><div style><br></div><div style>and here is the result of the layer options:</div><div style><br></div><div style><div>The layer is {</div>
<div>    "my_wms_layer": {</div><div>        "base_url": "<a href="http://gis.site.org:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=MyMap:my_layer">http://gis.site.org:8080/geoserver/wms?service=WMS&version=1.1.0&request=GetMap&layers=MyMap:my_layer</a>",</div>
<div>        "params": {</div><div>            "isBaseLayer": 0,</div><div>            "buffer": 2,</div><div>            "ratio": 1.5,</div><div>            "singleTile": 0,</div>
<div>            "resolutions": [</div><div>                156543.0339,</div><div>                78271.51695,</div><div>                39135.758475,</div><div>                19567.8792375,</div><div>                9783.93961875,</div>
<div>                4891.969809375,</div><div>                2445.9849046875,</div><div>                1222.9924523438,</div><div>                611.49622617188,</div><div>                305.74811308594,</div><div>                152.87405654297,</div>
<div>                76.437028271484,</div><div>                38.218514135742,</div><div>                19.109257067871,</div><div>                9.5546285339355,</div><div>                4.7773142669678,</div><div>                2.3886571334839,</div>
<div>                1.1943285667419,</div><div>                0.59716428337097</div><div>            ],</div><div>            "projection": {</div><div>                "projCode": "EPSG:900913"</div>
<div>            },</div><div>            "maxextent": [</div><div>                -20037508,</div><div>                -20037508,</div><div>                20037508,</div><div>                20037508</div><div>
            ],</div><div>            "drupalID": "my_wms_layer",</div><div>            "units": "m",</div><div>            "maxExtent": {</div><div>                "left": -20037508.34,</div>
<div>                "bottom": -20037508.34,</div><div>                "right": 20037508.34,</div><div>                "top": 20037508.34</div><div>            }</div><div>        },</div><div>
        "options": {</div><div>            ...rname": "world-bright",</div><div>        "layer_type": "openlayers_layer_type_mapbox",</div><div>        "osm": false,</div>
<div>        "baselayer": true,</div><div>        "type": "png",</div><div>        "resolutions": [</div><div>            156543.0339,</div><div>            78271.51695,</div><div>            39135.758475,</div>
<div>            19567.8792375,</div><div>            9783.93961875,</div><div>            4891.969809375,</div><div>            2445.9849046875,</div><div>            1222.9924523438,</div><div>            611.49622617188,</div>
<div>            305.74811308594,</div><div>            152.87405654297,</div><div>            76.437028271484</div><div>        ],</div><div>        "projection": {</div><div>            "projCode": "EPSG:900913"</div>
<div>        },</div><div>        "serverResolutions": [</div><div>            156543.0339,</div><div>            78271.51695,</div><div>            39135.758475,</div><div>            19567.8792375,</div><div>            9783.93961875,</div>
<div>            4891.969809375,</div><div>            2445.9849046875,</div><div>            1222.9924523438,</div><div>            611.49622617188,</div><div>            305.74811308594,</div><div>            152.87405654297,</div>
<div>            76.437028271484,</div><div>            38.218514135742,</div><div>            19.109257067871,</div><div>            9.5546285339355,</div><div>            4.7773142669678,</div><div>            2.3886571334839,</div>
<div>            1.1943285667419,</div><div>            0.59716428337097</div><div>        ],</div><div>        "maxExtent": {</div><div>            "left": -20037508,</div><div>            "bottom": -20037508,</div>
<div>            "right": 20037508,</div><div>            "top": 20037508</div><div>        },</div><div>        "layer_handler": "MapBox",</div><div>        "title": "MapBox World Bright",</div>
<div>        "weight": 0,</div><div>        "drupalID": "mapbox_world_bright",</div><div>        "isBaseLayer": true</div><div>    }</div><div>}</div></div><div><br></div><div style>
so it seems that "<span style="font-family:arial,sans-serif;font-size:13px">SphericalMercator: true</span>" is missing in both the map and the layer (my_wms_layer), would you say this is the reason of why the WMS bound box parameter is incorrect when open layer fetches the different png images of the map?</div>
<div style><br></div><div style>Thanks !!</div><div style>Alex</div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 9 January 2013 18:14, Gery . <span dir="ltr"><<a href="mailto:gamejihou@hotmail.com" target="_blank">gamejihou@hotmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div><div dir="ltr">
<br>>                  "Peru WMS",<br><font style="font-size:10pt" color="#1F497D" face="Arial"><br><font style="font-size:10pt"><font style="font-size:10pt">cool =)</font></font><br>__________________________________________________________________________________________<br>
Piensa en el medio ambie<font face="Arial">nte - mantenlo en la pantalla. NO lo imprimas si NO es necesario.</font></font><font style="font-size:10pt" color="#1F497D" face="Arial"><br></font><font style="font-size:10pt" color="#1F497D" face="Arial">Think green - keep it on the screen. Do NOT print if it is NOT necessary.</font><font style="font-size:10pt" color="#1F497D" face="Arial"><br>
</font><font style="font-size:10pt" color="#1F497D" face="Arial"><span lang="de"><span>Denken Sie an</span> <span>die Umwelt</span></span></font><font style="font-size:10pt" color="#1F497D" face="Arial"><span lang="de"><span></span> <span>-</span> <span>bewahren Sie es</span> <span>auf dem Bildschirm.</span> <span>Drucken Sie NICHT</span><span>, wenn</span> <span>es NICHT notwendig ist</span><span>.</span></span></font><br>
<br><br><div><div></div>> Date: Wed, 9 Jan 2013 17:57:53 -0500<br>> From: <a href="mailto:woodbri@swoodbridge.com" target="_blank">woodbri@swoodbridge.com</a><br>> To: <a href="mailto:openlayers-users@lists.osgeo.org" target="_blank">openlayers-users@lists.osgeo.org</a><br>
> Subject: Re: [OpenLayers-Users] OpenLayers with 900913 projection and drupal OpenLayers module<div><div class="h5"><br>> <br>> On 1/9/2013 5:49 PM, Alexander Kocisky wrote:<br>> > Hi all,<br>> ><br>
> > I've set up a Geoserver/PostGIS infrastructure in order to render a<br>> > database of GIS information. Initially i was working with the projection<br>> > 4326 but when i've installed Drupal + OpenLayers i've realized that<br>
> > there are almost no tiles with this projection, the way to go seems the<br>> > projection 900913.<br>> ><br>> > So i've converted all my gis objects to 900913, verified that i could<br>> > see the rendered points in the geoserver Layer Preview with OpenLayer<br>
> > and tried to add the WMS layer to my map created with Drupal Openlayer<br>> > module.<br>> ><br>> > It apparently works but it fetches a bound box that is wrong, in fact if<br>> > i modify manually the request urls (from the browser) i get the correct<br>
> > data. I need to understand better how this bounded box works, how is it<br>> > initially set? i guess that for each png image downloaded there is a<br>> > specific BBOX parameter, is this done by the Openlayers library?<br>
> ><br>> > I've also explained the issue on the drupal openlayers module but<br>> > apparently it was never really tested with WMS 900931 (weird right?) .<br>> > The module works well with the same configuration and the 4326<br>
> > projection (<a href="http://drupal.org/node/1884422" target="_blank">http://drupal.org/node/1884422</a>).<br>> ><br>> > Please let me know if you have any suggestion.<br>> > Thanks!!<br>> ><br>
> > Alex<br>> <br>> Alex,<br>> <br>> I think you need to post how the OL map and layer objects are defined or <br>> post a link to your site if it is public.<br>> <br>> More than likely you have left off something like: SphericalMercator: true<br>
> <br>> <br>> Here is what I use:<br>> <br>>              map = new OpenLayers.Map('map', {<br>>                  maxResolution: 156543.0339/2,<br>>                  numZoomLevels: 18,<br>>                  units: 'm',<br>
>                  maxExtent: new OpenLayers.Bounds(-20037508.34, <br>> -20037508.34, 20037508.34, 20037508.34),<br>>                  sphericalMercator: true,<br>>                  projection: epsg900913,<br>
>                  displayProjection: epsg4326,<br>>                  controls:[<br>>                      new OpenLayers.Control.LayerSwitcher(),<br>>                      // new OpenLayers.Control.OverviewMap(),<br>
>                      new OpenLayers.Control.Permalink('permalink'),<br>>                      new OpenLayers.Control.MouseToolbar(),<br>>                      new OpenLayers.Control.MousePosition(),<br>
>                      new OpenLayers.Control.PanZoomBar(),<br>>                      new OpenLayers.Control.Scale(),<br>>                      new OpenLayers.Control.ScaleLine()<br>>                  ]<br>>                  });<br>
> <br>>              var wms = new OpenLayers.Layer.WMS(<br>>                  "Peru WMS",<br>>                  "<a href="http://server/cgi-bin/mapserv" target="_blank">http://server/cgi-bin/mapserv</a>?",<br>
>                  { map: "/u/data/mydata/peru4.map",<br>>                    format: "image/png",<br>>                    layers: "Peru4_4326_WMS"<br>>                  },<br>>                  {<br>
>                    sphericalMercator: true,<br>>                    transitionEffect: 'resize',<br>>                    singleTile: true,<br>>                    ratio: 1.0<br>>                  });<br>
>              wms.addOptions({isBaseLayer: true});<br>>              wms.setVisibility(false);<br>>              map.addLayer(wms);<br>> <br>> -Steve<br>> _______________________________________________<br>
> Users mailing list<br>> <a href="mailto:Users@lists.osgeo.org" target="_blank">Users@lists.osgeo.org</a><br>> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</div></div></div>                                      </div></div>
<br>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
<br></blockquote></div><br></div>