[OpenLayers-Users] OpenLayers with 900913 projection and drupal OpenLayers module

Stephen Woodbridge woodbri at swoodbridge.com
Wed Jan 9 14:57:53 PST 2013


On 1/9/2013 5:49 PM, Alexander Kocisky wrote:
> Hi all,
>
> I've set up a Geoserver/PostGIS infrastructure in order to render a
> database of GIS information. Initially i was working with the projection
> 4326 but when i've installed Drupal + OpenLayers i've realized that
> there are almost no tiles with this projection, the way to go seems the
> projection 900913.
>
> So i've converted all my gis objects to 900913, verified that i could
> see the rendered points in the geoserver Layer Preview with OpenLayer
> and tried to add the WMS layer to my map created with Drupal Openlayer
> module.
>
> It apparently works but it fetches a bound box that is wrong, in fact if
> i modify manually the request urls (from the browser) i get the correct
> data. I need to understand better how this bounded box works, how is it
> initially set? i guess that for each png image downloaded there is a
> specific BBOX parameter, is this done by the Openlayers library?
>
> I've also explained the issue on the drupal openlayers module but
> apparently it was never really tested with WMS 900931 (weird right?) .
> The module works well with the same configuration and the 4326
> projection (http://drupal.org/node/1884422).
>
> Please let me know if you have any suggestion.
> Thanks!!
>
> Alex

Alex,

I think you need to post how the OL map and layer objects are defined or 
post a link to your site if it is public.

More than likely you have left off something like: SphericalMercator: true


Here is what I use:

             map = new OpenLayers.Map('map', {
                 maxResolution: 156543.0339/2,
                 numZoomLevels: 18,
                 units: 'm',
                 maxExtent: new OpenLayers.Bounds(-20037508.34, 
-20037508.34, 20037508.34, 20037508.34),
                 sphericalMercator: true,
                 projection: epsg900913,
                 displayProjection: epsg4326,
                 controls:[
                     new OpenLayers.Control.LayerSwitcher(),
                     // new OpenLayers.Control.OverviewMap(),
                     new OpenLayers.Control.Permalink('permalink'),
                     new OpenLayers.Control.MouseToolbar(),
                     new OpenLayers.Control.MousePosition(),
                     new OpenLayers.Control.PanZoomBar(),
                     new OpenLayers.Control.Scale(),
                     new OpenLayers.Control.ScaleLine()
                 ]
                 });

             var wms = new OpenLayers.Layer.WMS(
                 "Peru WMS",
                 "http://server/cgi-bin/mapserv?",
                 { map: "/u/data/mydata/peru4.map",
                   format: "image/png",
                   layers: "Peru4_4326_WMS"
                 },
                 {
                   sphericalMercator: true,
                   transitionEffect: 'resize',
                   singleTile: true,
                   ratio: 1.0
                 });
             wms.addOptions({isBaseLayer: true});
             wms.setVisibility(false);
             map.addLayer(wms);

-Steve


More information about the Users mailing list