Fwd: [OpenLayers-Users] WFS reprojection on Google Maps
Luís de Sousa
luis.a.de.sousa at gmail.com
Thu May 5 05:03:43 EDT 2011
Thank you Charles for the hint, but the result is exactly the same.
As far as I understand the reprojection is performed by the WFS
server, right? Could this be an issue server side?
Thank you,
Luís
2011/5/4 Charles Galpin <cgalpin at lhsw.com>:
> Hi Luis
>
> I remember having trouble getting this right when I first started using openlayers. Once I figured it out, I kept using the same basic setup so I don't remember the details, but this is what I use for my map options. Perhaps give them a try.
>
> var options = {
> // the "community" epsg code for spherical mercator
> projection: "EPSG:900913",
> displayProjection: new OpenLayers.Projection("EPSG:4326"),
>
> // map horizontal units are meters
> units: "m",
>
> // this resolution displays the globe in one 256x256 pixel tile
> maxResolution: 78271.51695,
>
> // these are the bounds of the globe in sperical mercator
> maxExtent: new OpenLayers.Bounds(-20037508, -20037508,
> 20037508, 20037508)
> };
> hth
> charles
>
> On May 4, 2011, at 5:51 AM, Luís de Sousa wrote:
>
>> Dear all,
>>
>> I've been trying to reproject WFS layers on Google Maps without
>> success. After reading several threads here and elsewhere it became
>> apparent that WFS 1.1.0 takes care of reprojections by itself, without any
>> processing needed client side. Hence I tried simply to reproject the
>> Tazmania shapes from Geoserver on a Google Maps base layer; while the
>> WFS layers are indeed there, they do not seem to have been reprojected:
>>
>> http://www.flickr.com/photos/46630302@N04/5686739802/in/set-72157626519940667/
>>
>> Below goes the code, note that I'm using a local version of Geoserver
>> on port 8090. I'd thank if anyone could hint at what I'm missing.
>>
>> Thanks,
>>
>> Luís
>>
>> -----
>>
>> <html xmlns="http://www.w3.org/1999/xhtml">
>> <head>
>> <style type="text/css">
>> #map {
>> width: 560px;
>> height: 460px;
>> border: 1px solid black;
>> }
>> </style>
>>
>> <script src="http://localhost:8090/geoserver/www/OpenLayers-2.9/OpenLayers.js"
>> type="text/javascript"></script>
>>
>> <!-- Google API-->
>> <script src='http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAjpkAC9ePGem0lIq5XcMiuhR_wWLPFku8Ix9i2SXYRVK3e45q1BQUd_beF8dtzKET_EteAjPdGDwqpQ'></script>
>>
>> <script defer="defer" type="text/javascript">
>>
>> function init(){
>>
>> var map = new OpenLayers.Map("map", {
>> projection: new OpenLayers.Projection("EPSG:900913")
>> });
>>
>> var gphy = new OpenLayers.Layer.Google(
>> "Google Physical",
>> {type: G_PHYSICAL_MAP}
>> );
>>
>> var roads = new OpenLayers.Layer.WFS(
>> "Roads",
>> "http://localhost:8090/geoserver/wfs",
>> {typename: 'topp:tasmania_roads'},
>> {
>> typename: 'tasmania_roads',
>> featureNS: 'http://www.openplans.org/topp',
>> extractAttributes: false,
>> version: "1.1.0",
>> srsName: "EPSG:900913"
>> }
>> );
>> roads.style = OpenLayers.Util.applyDefaults(
>> {strokeWidth: 2, strokeColor: "#ff0000"},
>> OpenLayers.Feature.Vector.style["default"]);
>>
>> var states = new OpenLayers.Layer.WFS(
>> "States",
>> "http://localhost:8090/geoserver/wfs",
>> {typename: 'topp:tasmania_state_boundaries'},
>> {
>> typename: 'tasmania_state_boundaries',
>> featureNS: 'http://www.openplans.org/topp',
>> extractAttributes: false,
>> version: "1.1.0",
>> srsName: "EPSG:900913"
>> }
>> );
>> states.style = OpenLayers.Util.applyDefaults(
>> {strokeWidth: 3, strokeColor: "#333333"},
>> OpenLayers.Feature.Vector.style["default"]);
>>
>> map.addLayers([gphy, roads, states]);
>>
>> map.addControl(new OpenLayers.Control.Navigation());
>> map.addControl(new OpenLayers.Control.LayerSwitcher());
>>
>> map.setCenter(new OpenLayers.LonLat(147, -42), 7);
>>
>> }
>> </script>
>>
>> </head>
>> <body onload="init()">
>> <h5>This is a reprojection test on Google Maps.</h5>
>> <div id="map"> </div>
>> </body>
>> </html>
>> _______________________________________________
>> Users mailing list
>> Users at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
More information about the Users
mailing list