On 8/8/2011 4:53 AM, Julien Cigar wrote:
This is a common pitfall when using OpenLayers. The SRS parameter will
be ignored. Always. Instead, WMS layers will be requested in the SRS
used by your base layer.
Thanks for this enlightenment.. which is quite logical in fact, there is
no reasons to have overlays in another projection than the base layer ...

Actually, we had a situation at a previous project where the remote WMS service was unwilling to add new a SRS to their list. Since we wanted to overlay their WMS onto a Spherical Mercator map, we made a simple change to Layer/WMS.js which adds dynamic reprojection.

I have attached the patched WMS.js file. It defines a new layer type: OpenLayers.Layer.ReprojectingWMS The magic is that last paragraph in getFullRequestString() It adds a check for layer.params.SRS and then reprojects the tile's bbox to make up the WMS request parameters.


Simply add the "srs" parameter to your third argument (the WMS params) as you would any other WMS request param.

Caveat: EPSG:23031 (a European UTM) and Google's 900913 tend to convert very strangely UNLESS you also load proj4js. If you're reprojecting, I highly recommend proj4js be used. That's easy, though: download the package and add the 4 <script> tags and OpenLayers will configure itself when it loads and detects proj4js.

Complaint: If we were to go back and clean up, we would simply assign OpenLayers.Layer.WMS.getFullRequestString() instead of naming it a new class. The WMSGetFeatureInfo control has hardcoded into it a list of layer types, and ReprojectingWMS is not on the list -- so this layer is not considered a candidate for a query. The workarounds for that aren't too onerous though.

--
Greg Allensworth, Web GIS Developer
BS  A+  Network+  Security+  Linux+  Server+
GreenInfo Network - Information and Mapping in the Public Interest
564 Market Street, Suite 510  San Francisco CA 94104
PH: 415-979-0343 x302  FX: 415-979-0371    email: [email protected]
Web: www.GreenInfo.org     www.MapsPortal.org

Subscribe to MapLines, our e-newsletter, at www.GreenInfo.org

Attachment: WMS.js
Description: JavaScript source

_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users

Reply via email to