5

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.

1 Answer 1

4

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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