[OpenLayers-Users] WMS overlay with Google and OSM

Jean-François Gigand jf at geonef.fr
Fri Aug 12 11:20:50 EDT 2011


Hi Dan,

The WMS URL in your case yould be only
"http://warehouse1.indicia.org.uk:8080/geoserver/wms?".
Other static parameters like "styles" and "layers" should be set
through the layer's "params" property.
Parameters like "bbox", "width", "heigth" and "srs" are managed by OpenLayers.

Since your map is in the EPSG:900913 projection, your GeoServer should
be configured to serve your WMS map in that same projection.

You can check what WMS requests are made by inspecting the URL of the
tiles (or through Firebug's "network" tab):
it would contain srs=EPSG:900913.

Best regards,

Jean-François Gigand - Geonef
Paris, France - http://geonef.fr/



2011/8/12 Dan Lear <dble at mba.ac.uk>:
> Hi,
>
> I have the following code (mostly lifted from the OL examples):
>
> <script type="text/javascript">
>        var lon = 5;
>        var lat = 40;
>        var zoom = 5;
>        var map, select;
>
>        function init(){
>            var options = {
>                projection: new OpenLayers.Projection("EPSG:900913"),
>                displayProjection: new OpenLayers.Projection("EPSG:4326"),
>                units: "m",
>                maxResolution: 156543.0339,
>                maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
>                                                 20037508.34, 20037508.34)
>            };
>            map = new OpenLayers.Map('map', options);
>            var mapnik = new OpenLayers.Layer.OSM("OpenStreetMap (Mapnik)");
>            var gmap = new OpenLayers.Layer.Google("Google", {sphericalMercator:true});
>
> var dm_wms = new OpenLayers.Layer.WMS(
>    "Crab Data",
>    "http://warehouse1.indicia.org.uk:8080/geoserver/wms?bbox=-142385,6693234,25943,6710384&styles=dist_point_blue&Format=image/png&request=GetMap&version=1.1.1&layers=risc:mitten_crab_all&width=800&height=300&srs=EPSG:4326&cql_filter=record_status=%27C%27"
>    ,
>    {isBaseLayer: false, visibility: false}
> );
>
>
>            map.addLayers([mapnik, gmap, dm_wms]);
>
>
>            map.addControl(new OpenLayers.Control.LayerSwitcher());
>
>            map.zoomToExtent(
>                new OpenLayers.Bounds(
>                    68.774414, 11.381836, 123.662109, 34.628906
>                ).transform(map.displayProjection, map.projection)
>            );
>        }
>
>    </script>
>
> Which I want overlay the WMS from a Geoserver instance (dm_wms), but it isn't displaying, I suspect it's a projection issue, but don't understand enough to fix it! Also need the map to set focus on the UK, is there somewhere I can find the bounds required or is it just a case of trial and error?
>
> Thanks for any help received,
> Dan
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>


More information about the Users mailing list