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.

Here is the thing. I added the Scale control to my web and is displayed in a div at the bottom. I need to translate the "Scale" text to other language but I can't find how to do it. I searched in the openlayers website for examples or code to do it without results. None of the properties of Scale control tell me how to do this (in openlayers website).

So I ask to you, people, if you know some method to customize this feature.

Here is the code I use in my script:

map.addControl(new OpenLayers.Control.Scale($('scale')));

and this is the div where I displayed:

    <div id="wrapper">
       <div id="location"></div>
       <div id="scale"></div>
    </div>

I tried with writing the label in the div but the scale control overwrite the label. Hope you can help me with this.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

I agree, the documentation is a bit limited when it comes to internationalization. For changing the text in controls, here's how it works (using German as an example language). First you need to import the language file into your html document:

<script src="<path to>/lib/OpenLayers/Lang/de.js" type="text/javascript"></script>

Then, set the language in the javascript file where you call map.addControl

function init() {
    OpenLayers.Lang.setCode("de");
    ...
}

That should update the language of your controls labels.

You will find the list of available languages and the corresponding codes here.

share|improve this answer
    
Thank you very much katahdin, it works wonderfully. –  Daeron Alcarin Jan 13 '12 at 18:24

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.