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.
On the protocol definition, you need to set srsName:
new OpenLayers.Layer.Vector('Wells', {
strategies: [new OpenLayers.Strategy.BBOX(), config.saveStrategy],
protocol: new OpenLayers.Protocol.WFS({
url: config.vectorWfs,
featureType: "Wells_PRS",
featureNS: "http://gisxxxx",
geometryName: "GEOM",
srsName: 'EPSG:4326'
}),
version: "1.1.0"
}),
You do not need proj4js.
Best Answer
you could use this:
see: http://jsfiddle.net/expedio/2xvfbtdw/
or even use a stylemap with different style for default and select:
see: http://jsfiddle.net/expedio/yxr5wdjo/
nice website with Information about the Feature-Style and Stylemap: http://www.peterrobins.co.uk/it/olstyle.html
PS: Just for demonstration purposes: If you open your website and use the console of your debug-tool (firebug for example) you run this code in your developer tools (non permanent change of course):
have a look at the screenshot: