Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I am familiarizing myself with Openlayers, and am having trouble with understanding the projection and displayprojection properties for a Map.

When the map is initialized with the following code:

map = new OpenLayers.Map('map', {           
        numZoomLevels: 20,
        projection: new OpenLayers.Projection("EPSG:900913"),
        displayProjection: new OpenLayers.Projection("EPSG: 4326")
        });

What exactly is happening?

The documentation of the OpenLayers.Map says that

projection -Set in the map options to override the default projection string [in] this map - also set maxExtent, maxResolution, and units if appropriate. Default is “EPSG:4326”.

while displayProjection is the Projection used by several controls to display data to user. If this property is set, it will be set on any control which has a null displayProjection property at the time the control is added to the map.

This does not make it clear.

Could someone explain what exactly do these two option do?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

From the OpenLayers Beginner's guide:

This is a property that is used mainly by controls which show coordinate information. By setting this property on the map object, any control that has a displayProjection property will be set to this value. Controls, such as the MousePosition control, can display coordinates in the displayProjection. So, your map could be in a different projection than what you wish to display the coordinates in. However, to use a displayProjection other than EPSG:4326 or EPSG:900913, Proj4js must be included on your page. This property comes in very handy if, for instance, your map is in a spherical Mercator projection (i.e., EPSG:900913), but you might wish to display coordinates in another projection, like EPSG:4326 (to display lon/lat coordinates).

The bold parts should give you an idea. I hope it helps.

share|improve this answer
    
So to clarify, Projection is the coordinate system of the map, while displayProjection is the coordinate system used only by controls like Permalink & MousePosition etc. –  Devdatta Tengshe Oct 8 '12 at 7:00
    
Yes. More or less. Controls that show coordinate information. –  R.K. Oct 8 '12 at 7:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.