[OpenLayers-Users] GoogleMaps and Layers with differents projections

Gregor at HostGIS gregor at hostgis.com
Thu Jan 14 11:41:16 EST 2010


I managed to accomplish this a few days ago; rather a colleague did and 
he shared the mechanism with me. My implementation of his solution is 
here. It uses Google basemaps, and WMS overlays from servers which only 
do EPSG:23031.
    http://eixos.planol.info/google/

This involves some light hacks, and are not supported by OpenLayers. For 
one, it loads the map as 4326 instead of 900913, and does not use the 
modern sphericalMercator mechanism. But it did get the job done when 
nothing else could!

In our case it also solves an issue I've had repeatedly with data in 
23031 never aligning with Google Maps, even when I could control the WMS 
server and allow requests in EPSG:900913 That's what started this whole 
quest last week, really bad drift when using the proper mechanisms.

Description:

* Note in View Source, the use of proj4js and the loading of one 
not-already-known projection, EPSG:23031

* Note in View Source the loading of a new WMS class, which is basically 
a modified clone of OpenLayers.Layer.WMS It would have been nicer to 
subclass instead, but being in a hurry and their code already working I 
just went with their version. The magic comes in getFullRequestString() 
where it uses proj4js to reproject the BBOX in the request URL. Note the 
use of 94326 and p23031 as defined in map.js

* In map.js note that the map is declared as EPSG:4326 and NOT using the 
sphericalMercator mechanism. Individual WMS layers specify the SRS 
parameter in the WMS params. As you saw in WMS.class.js, it is this SRS 
which triggers reprojection of the request BBOX.

Again, this is not the proper and supported mechanisms, and how Google 
Maps layers work with the map declared as 4326 is unknown to me and may 
not work in future versions of OL. But, this mechanism did allow us to 
mix SRSs when we can't convince the WMS servers to allow 900913, and 
solved a perennial problem we had with drift in Barcelona.

-- 
HostGIS, Open Source solutions for the global GIS community
Greg Allensworth - SysAdmin, Programmer, GIS Person, Security
    Network+   Server+   A+   Security+   Linux+
    PHP   PostgreSQL   MySQL   DHTML/JavaScript/AJAX

"No one cares if you can back up — only if you can recover."



More information about the Users mailing list