[OpenLayers-Users] SphericalMercator and SRS aliases
epsg:900913, epsg:3857, epsg:3785, epsg:102113
Arnd Wippermann
arnd.wippermann at web.de
Sun Jul 25 16:17:40 EDT 2010
Hi,
I wouldn't restrict it to sphericalmercatoralias. I use a similiar approach
to add WMS Server, which use a different EPSG code than my map, but describe
the same projection.
Why not use options.projection to request the WMS in this projection?
OpenLayers.Layer.WMS.prototype.getFullRequestString =
function(newParams,altUrl)
{
try{
var projectionCode = typeof this.options.projection == 'undefined' ?
this.map.getProjection() : this.options.projection;
}catch(err){
var projectionCode=this.map.getProjection();
}
var value = (projectionCode == "none") ? null : projectionCode
if (parseFloat(this.params.VERSION) >= 1.3) {
this.params.CRS = value;
} else {
this.params.SRS = value;
}
return OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this,
arguments);
},
Arnd
-----Ursprüngliche Nachricht-----
Von: users-bounces at openlayers.org [mailto:users-bounces at openlayers.org] Im
Auftrag von Anne Blankert
Gesendet: Sonntag, 25. Juli 2010 13:54
An: users at openlayers.org
Betreff: Re: [OpenLayers-Users] SphericalMercator and SRS aliases
epsg:900913, epsg:3857, epsg:3785, epsg:102113
Hmm,
I didn't test my code properly, (layers without option sphericalmercator
stopped working). The following code should do better (Version >= 1.3 not
yet tested):
// override OpenLayers.WMS.getFullRequestString class member function
OpenLayers.Layer.WMS.prototype.getFullRequestString = function(newParams,
altUrl) {
var projectionCode = this.map.getProjection();
var value = (projectionCode == "none") ? null : projectionCode
if (this.options.sphericalmercatoralias)
{
if(value == 'EPSG:900913' || value == 'EPSG:102113' || value
==
'EPSG:3857') {
value = this.options.sphericalmercatoralias;
}
}
if (parseFloat(this.params.VERSION) >= 1.3) {
this.params.CRS = value;
} else {
this.params.SRS = value;
}
return
OpenLayers.Layer.Grid.prototype.getFullRequestString.apply(this,
arguments);
}
After this override, you can set a new layeroption 'sphericalmercatoralias'
to tell OpenLayers to use that instead of the default as follows:
layer = new OpenLayers.Layer.WMS(title, url, {layers: layernames},
{sphericalmercatoralias: "EPSG:102113"});
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/SphericalMercator-and-SRS-aliases-eps
g-900913-epsg-3857-epsg-3785-epsg-102113-tp5311417p5334827.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
Users at openlayers.org
http://openlayers.org/mailman/listinfo/users
More information about the Users
mailing list