In OpenLayers, the base layer dictates what is going to be the "base spatial reference". So any overlay will be projected to the base srid. Since any base layer that comes from the consumer-based providers (google, bing, yahoo, etc) supports only 900913, then OpenLayers is doing the right thing for your.
If you do a GetCapabilities call on your server you will notice the following section:
<Layer queryable="1" opaque="0" noSubsets="0">
<Name>Catastro</Name>
<Title>Catastro</Title>
<Style>
<Name>Default</Name>
<Title>Default</Title>
<LegendURL width="160" height="500">
<Format>image/png</Format>
<OnlineResource xlink:type="simple" xlink:href="http://ovc.catastro.meh.es/Cartografia/WMS/simbolos.png"/>
</LegendURL>
</Style>
<BoundingBox SRS="EPSG:4230" minx="-18.409876" miny="26.275447" maxx="5.22598" maxy="44.85536"/>
<BoundingBox SRS="EPSG:4326" minx="-18.409876" miny="26.275447" maxx="5.22598" maxy="44.85536"/>
<BoundingBox SRS="EPSG:4258" minx="-18.409876" miny="26.275447" maxx="5.22598" maxy="44.85536"/>
<BoundingBox SRS="EPSG:32627" minx="770000" miny="3000000" maxx="2700000" maxy="5000000"/>
<BoundingBox SRS="EPSG:32628" minx="180000" miny="3000000" maxx="2170000" maxy="5000000"/>
<BoundingBox SRS="EPSG:23029" minx="-410000" miny="3000000" maxx="1650000" maxy="5000000"/>
<BoundingBox SRS="EPSG:23030" minx="-1050000" miny="3000000" maxx="1150000" maxy="5000000"/>
<BoundingBox SRS="EPSG:23031" minx="-1615000" miny="3000000" maxx="620000" maxy="5000000"/>
<BoundingBox SRS="EPSG:32629" minx="-410000" miny="3000000" maxx="1650000" maxy="5000000"/>
<BoundingBox SRS="EPSG:32630" minx="-1050000" miny="3000000" maxx="1150000" maxy="5000000"/>
<BoundingBox SRS="EPSG:32631" minx="-1615000" miny="3000000" maxx="620000" maxy="5000000"/>
<BoundingBox SRS="EPSG:25829" minx="-410000" miny="3000000" maxx="1650000" maxy="5000000"/>
<BoundingBox SRS="EPSG:25830" minx="-1050000" miny="3000000" maxx="1150000" maxy="5000000"/>
<BoundingBox SRS="EPSG:25831" minx="-1615000" miny="3000000" maxx="620000" maxy="5000000"/>
<BoundingBox SRS="EPSG:3785" minx="-2100000" miny="3000000" maxx="500000" maxy="5600000"/>
</Layer>
Lo and behold, 900913 is not an option. You may need to either:
- modify the WMS server definition to make sure that 900913 is allowed as a valid reprojection
- add a definition for that new srid (depends on what web server you are using)
- a combination of thse
By looking at the URL, it seems you are using an ASP .NET WMS server, since Geoserver is java and Mapserver if cgi, and ArcGIS Server is .NET, I am going guess this is an ESRI server, so the instructions on how to modify this is here.
Update: As mkennedy points out, the official EPSG code for SphericalMercator (aka Google's projection) is 3857 and a previous assigned number was 3785. If you are wondering why there are so many numbers that refer to the same spatial reference, crschmidt's blog post will give you a clue...
Ian pointed out the relevant OpenLayer's documentation section to force OpenLayers to use that EPSG code instead.
Since your GetCapabilities section shows 3785, the code from the OL documentation won't work as is, you will need to replace all the 3857 for 3785.
i want to say some solutions come to my mind.
1.check out GeoWebCache endpoint URL as http://example.com/geoserver/gwc/service/wms
for GeoWebCache WMS instead.
2.check out your geowebcache.xml and openlayers whether same projection or not.
3.check out GeoWebCache demo page from http://localhost:8080/geoserver/gwc/demo
.
4.check out your GeoWebCache Configuration, you can look an GWC Example here.
5.check out your param-value from cached tiles directory in web.xml(in web-inf dir) <param-value>C:\temp</param-value>
6.try to add tilesize and tileorigin to your wms option as
{ tileSize: new OpenLayers.Size(256,256),
tileOrigin: new OpenLayers.LonLat(-180.0, 90.0)});
These are some issues about gwc which i want you to check out that has come to my mind for now.
i hope it helps you...
Best Answer
if you have extjs, you can do it with this way:
i hope it helps you....