Hey,<br><br><br>Well, I've gotten the source code of this module, so now i'm trying to add a coeficient K .<br><br><br>The goal is to give the possibility to adjust the scaleline.<br>
<br>
For that, I thought that we can add two function on this module :<br>
<br>
<ol><li>float calculateTheCoefficient(float <span id="result_box" class="short_text" lang="en"><span title="Click for alternate translations" class="hps">length</span></span>, int pixels ); // length in meter , pixels number of pixels that the length represent<br>
</li><li>void setTheCoefficient ( float k );</li></ol>
<br>
The first function will calculate the coefficient with the actual resolution and the length/pixels .<br>
the second function will save the coefficient for the update function() .<br>
<br>
<br>
What do you think ? <br><br><br>My problem, is that i don't know how to do code the first function .......<br><br><br><br><br><br><br><font size="1"> update: function() {<br> var res = this.map.getResolution();<br>
<font size="2"><b> res*= k;</b></font><br> if (!res) {<br> return;<br> }<br><br> // convert maxWidth to map units<br> var maxSizeData = this.maxWidth * res; <br> <br> // decide whether to use large or small scale units <br>
var topUnits;<br> if(maxSizeData > 0.1) {<br> topUnits = this.topOutUnits;<br> } else {<br> topUnits = this.topInUnits;<br> }<br> <br> // and to map units units<br>
var curMapUnits = this.map.units;<br> var inches = OpenLayers.INCHES_PER_UNIT;<br> var topMax = maxSizeData * inches[curMapUnits] / inches[topUnits];<br> <br> // now trim this down to useful block length<br>
var topRounded = this.getBarLen(topMax);<br><br> // and back to display units<br> topMax = topRounded / inches[curMapUnits] * inches[topUnits];<br><br> // and to pixel units<br>
var topPx = topMax / res;<br> <br> // now set the pixel widths<br> this.eTop.style.width = Math.round(topPx) + "px";<br> <br> // and the values inside them<br>
this.eTop.innerHTML = topRounded + " " + topUnits; <br> },<br> <br> CLASS_NAME: "OpenLayers.Control.ScaleLine"<br> }</font><br><br><br><br><br><br><div class="gmail_quote">
On Thu, Mar 24, 2011 at 3:03 PM, mickal <span dir="ltr"><<a href="mailto:mickamusset@gmail.com">mickamusset@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Hi,<br>
<br>
The scale that the module displayed to me is not right, I mean :<br>
<br>
50 pixel => 1000km<br>
but in reality :<br>
50 pixel => 100 m<br>
<br>
is it possible to add a coefficient to this module ? to adjust the scale<br>
that it displayed.<br>
<br>
<br>
Because otherwise I have to change my map, and this process is very long.<br>
<br>
<br>
thx,<br>
<font color="#888888"><br>
--<br>
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6204219.html" target="_blank">http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6204219.html</a><br>
Sent from the OpenLayers Users mailing list archive at Nabble.com.<br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.osgeo.org">Users@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
</font></blockquote></div><br>