[OpenLayers-Users] SphericalMercator and SRS aliases epsg:900913, epsg:3857, epsg:3785, epsg:102113

Anne Blankert anne.blankert at geodan.nl
Mon Jul 19 07:09:37 EDT 2010


  Hello Bart,

I am not sure if

http://trac.openlayers.org/ticket/2665

takes care of the side effect that Control.Measure and MousePosition are 
no longer working properly after resetting the projection code?

Anne

On 7/19/2010 12:29 PM, Bart van den Eijnden (OSGIS) wrote:
> Hi Anne,
>
> in trunk this has been addressed, see:
>
> http://trac.openlayers.org/ticket/2665
>
> Best regards,
> Bart
>
>>    Hello list,
>>
>> OpenStreetMap and also some popular commercial mapservices (google,
>> bing, yahoo) are using the so called sphericalmercator projection.
>> OpenLayers has built-in support for this type of layer, inherited from
>> OpenLayers.Layer.SphericalMercator.
>>
>> If you use a sphericalmercator layer as a baselayer, you may want to
>> combine this with other layers. By default,  the openlayers
>> sphericalmercator baselayer uses SRS projection-code 'EPSG:900913' . So,
>> if you try to open an overlay, the overlay layer will be called with
>> parameter SRS=EPSG:900913.
>>
>> EPSG Code 900913 happens to be a bogus code, based on the word 'google'.
>> Perhaps due to the resemblance of '900913' and 'google' or due to other
>> reasons, there are now several other codes in use for the same projection:
>> EPSG:3857
>> EPSG:3785<= maybe because of a typo by someone somewhere?
>> EPSG:102113
>>
>> Some map-services have stopped supporting SRS=EPSG:900913 and this
>> raises a problem for openlayers sphericalmercator users. Instead of
>> displaying a map, these mapservices will respond with something like 'no
>> support for EPSG:900913'.
>>
>> The problem of overlaying sphericalmercator layers that do not support
>> epsg:900913 can be (partly) solved as follows:
>> Override the default srs code for sphericalmercator layers by explicitly
>> resetting the projection before adding the layer to a map:
>>
>> var osmLayer = new OpenLayers.Layer.OSM("OpenStreetMap"); // osmlayer is
>> now sphericalmercator with default epsg:900913
>> osmLayer.projection = new OpenLayers.Projection ("EPSG:3857"); //
>> osmlayer is now sphericalmercator with epsg:3857
>> map.addLayers ([osmLayer]);
>>
>> Overlay layers will now be requested with SRS=ESPG:3857
>>
>> However, resetting the code for the baselayer projection, causes trouble
>> for the controls for MousePosition and MeasureControl: distances and
>> coordinates are no longer presented in the correct projection.
>>
>> I solved this by adding the following lines of code to file
>> lib\OpenLayers\Layer\SphericalMercator.js
>> OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3857",
>>       OpenLayers.Layer.SphericalMercator.projectForward);
>> OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:102113",
>>       OpenLayers.Layer.SphericalMercator.projectForward);
>> OpenLayers.Projection.addTransform("EPSG:4326", "EPSG:3785",
>>       OpenLayers.Layer.SphericalMercator.projectForward);
>>
>> OpenLayers.Projection.addTransform("EPSG:3857", "EPSG:4326",
>>       OpenLayers.Layer.SphericalMercator.projectInverse);
>> OpenLayers.Projection.addTransform("EPSG:102113", "EPSG:4326",
>>       OpenLayers.Layer.SphericalMercator.projectInverse);
>> OpenLayers.Projection.addTransform("EPSG:3785", "EPSG:4326",
>>       OpenLayers.Layer.SphericalMercator.projectInverse);
>>
>> Questions:
>> - is this the way to support aliases for 900913 and support
>> MousePosition and MeasureControl at the same time?
>> - if yes, shouldn't the above lines be part of the standard OpenLayers
>> distribution?
>>
>> Anne Blankert
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at openlayers.org
>> http://openlayers.org/mailman/listinfo/users
>>
>






More information about the Users mailing list