Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have used openlayers along with geoserver. My Map is having LCC projection by default, but SRS is EPSG:4042.

The problem is that the scaleline shows NaN in meter as well as feet. How can I correct it?

var bounds = new OpenLayers.Bounds(
    66.76242541918388, 6.756367055683252,
    98.64805108111362, 37.558217731396034
);

var map = new OpenLayers.Map('map',
    {
        maxExtent: bounds,
        maxResolution: 0.10,
        projection: "EPSG:4042",
    center: new OpenLayers.LonLat(79, 21)
     }
);

EDIT 1 :
This happens only when I give a projection for OpenLayers.Map. Otherwise, the scale is correct.

EDIT 2: This worked for me:

var bounds = new OpenLayers.Bounds(
    66.76242541918388, 6.756367055683252,
    98.64805108111362, 37.558217731396034
);

var map = new OpenLayers.Map('map',
    {
        maxExtent: bounds,
        maxResolution: 0.10,
        //projection: "EPSG:4042",
    center: new OpenLayers.LonLat(79, 21)
     }
);

i.e. commenting out projection.

share|improve this question
    
Is the scaleline generated by OpenLayers or is it a GeoServer map decoration? – Andrea Aime Aug 31 '12 at 6:23
    
It's generated by openlayers via API OpenLayers.Control.ScaleLine – Vineet Menon Aug 31 '12 at 7:36

You should add parameter to map: units: "m"

var map = new OpenLayers.Map('map',
 {
    units : 'm', // <-define units
    maxExtent: bounds,
    maxResolution: 0.10,
    //projection: "EPSG:4042",
    center: new OpenLayers.LonLat(79, 21)
  }
);
share|improve this answer

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.