[OpenLayers-Users] WFS reprojection on Google Maps

Andreas Hocevar ahocevar at opengeo.org
Thu May 5 12:39:55 EDT 2011


If you set a center without a zoom level, and use singleTile: true for
the WMS layer, I'm sure the tile bounds for the WMS layer are invalid
because they cross the date line. So either set an appropriate zoom
level, or don't use singleTile: true.

Andreas.

2011/5/5 Luís de Sousa <luis.a.de.sousa at gmail.com>:
> Hi Andreas et al.,
>
> Things with WFS are working fine, but WMS layers are getting
> reprojected, they don't even show up in the map. The code is below,
> thank you,
>
> Luís
>
> ----
>
> <html xmlns="http://www.w3.org/1999/xhtml">
>    <head>
>        <meta name="viewport" content="width=device-width; initial-scale=1.0;
> maximum-scale=1.0; user-scalable=0;" />
>        <meta name="apple-mobile-web-app-capable" content="yes" />
>
>        <style type="text/css">
>            #map {
>                width: 560px;
>                height: 460px;
>                border: 1px solid black;
>            }
>        </style>
>
>        <script src="http://localhost:8090/geoserver/www/OpenLayers-2.10/OpenLayers.js"
> type="text/javascript"></script>
>
>        <!-- Google API-->
>        <script src="http://maps.google.com/maps/api/js?v=3.3&amp;sensor=false"></script>
>
>        <script defer="defer" type="text/javascript">
>
>        var map;
>
>        function init() {
>
>            var extent = new OpenLayers.Bounds(
>                -11593508, 5509847, -11505759, 5557774
>            );
>
>            var options = {
>               projection: "EPSG:900913",
>               displayProjection: new OpenLayers.Projection("EPSG:4326"),
>               units: "m",
>               maxResolution: 78271.51695,
>               maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
>                                                20037508, 20037508),
>               restrictedExtent: extent,
>            };
>
>            map = new OpenLayers.Map('map');
>            map.addControl(new OpenLayers.Control.LayerSwitcher());
>
>            var gphy = new OpenLayers.Layer.Google(
>                "Google Physical",
>                {type: google.maps.MapTypeId.TERRAIN}
>            );
>
>            var wms  = new OpenLayers.Layer.WMS(
>                    "tasmania_roads",
>                    "http://localhost:8090/geoserver/wms",
>                    {
>                        layers: 'topp:tasmania_roads',
>                        transparent: true
>                    },
>                    {
>                        isBaseLayer: false,
>                        singleTile: true,
>                        ratio: 1
>                    }
>                );
>
>            map.addLayers([gphy, wms]);
>
>            map.setCenter(new OpenLayers.LonLat(147, -42).transform(
>                new OpenLayers.Projection("EPSG:4326"),
>                map.getProjectionObject()
>            ), 7);
>        }
>
>        </script>
>
>    </head>
>    <body onload="init()">
>        <h5>This is a test with Google Maps v3.</h5>
>        <div id="map" class="smallmap"></div>
>
>    </body>
> </html>
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.


More information about the Users mailing list