I really would like that it was simple !<br><br>But it&#39;s not, the map is come from a dxf file ( dxf2shp with qgis ).<br><br>So the scale is not respected.<br><br>Thx,<br><br><div class="gmail_quote">On Thu, Mar 24, 2011 at 10:35 PM, Andreas Hocevar-2 [via OSGeo.org] <span dir="ltr">&lt;<a href="/user/SendEmail.jtp?type=node&node=6208637&i=0&by-user=t" target="_top" rel="nofollow" link="external">[hidden email]</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">

        I think your map and/or layer configuration must be wrong. Usually this kind of problem appears when your map units don&#39;t match the projection&#39;s distance units.
<br><br>I&#39;d say there is no need to introduce a coefficient. Check your projection, and configure the map or base layer with the according units.
<br><br>Regards,
<br>Andreas.
<br><br>On Mar 24, 2011, at 19:03 , Micka wrote:
<br></div><div><div><div></div><div class="h5"><div class='shrinkable-quote'><br>&gt; Hey,
<br>&gt; 
<br>&gt; 
<br>&gt; Well, I&#39;ve gotten the source code of this module, so now i&#39;m trying to add a coeficient K .
<br>&gt; 
<br>&gt; 
<br>&gt; The goal is to give the possibility to adjust the scaleline.
<br>&gt; 
<br>&gt; For that, I thought that we can add two function on this module :
<br>&gt; 
<br>&gt;         • float calculateTheCoefficient(float length, int pixels );      // length in meter , pixels number of pixels that the length represent
<br>&gt;         • void setTheCoefficient ( float k );
<br>&gt; 
<br>&gt; The first function will calculate the coefficient with the actual resolution and the length/pixels .
<br>&gt; the second function will save the coefficient for the update function() .
<br>&gt; 
<br>&gt; 
<br>&gt; What do you think ? 
<br>&gt; 
<br>&gt; 
<br>&gt; My problem, is that i don&#39;t know how to do code the first function .......
<br>&gt; 
<br>&gt; 
<br>&gt; 
<br>&gt; 
<br>&gt; 
<br>&gt; 
<br>&gt;    update: function() {
<br>&gt;         var res = this.map.getResolution();
<br>&gt;         res*= k;
<br>&gt;         if (!res) {
<br>&gt;             return;
<br>&gt;         }
<br>&gt; 
<br>&gt;         // convert maxWidth to map units
<br>&gt;             var maxSizeData = this.maxWidth * res; 
<br>&gt;     
<br>&gt;         // decide whether to use large or small scale units     
<br>&gt;             var topUnits;
<br>&gt;             if(maxSizeData &gt; 0.1) {
<br>&gt;               topUnits = this.topOutUnits;
<br>&gt;             } else {
<br>&gt;               topUnits = this.topInUnits;
<br>&gt;             }
<br>&gt;     
<br>&gt;         // and to map units units
<br>&gt;             var curMapUnits = this.map.units;
<br>&gt;             var inches = OpenLayers.INCHES_PER_UNIT;
<br>&gt;             var topMax = maxSizeData * inches[curMapUnits] / inches[topUnits];
<br>&gt;     
<br>&gt;             // now trim this down to useful block length
<br>&gt;             var topRounded = this.getBarLen(topMax);
<br>&gt; 
<br>&gt;             // and back to display units
<br>&gt;             topMax = topRounded / inches[curMapUnits] * inches[topUnits];
<br>&gt; 
<br>&gt;             // and to pixel units
<br>&gt;             var topPx = topMax / res;
<br>&gt;            
<br>&gt;             // now set the pixel widths
<br>&gt;             this.eTop.style.width = Math.round(topPx) + &quot;px&quot;;
<br>&gt;            
<br>&gt;             // and the values inside them
<br>&gt;             this.eTop.innerHTML = topRounded + &quot; &quot; + topUnits;    
<br>&gt;         },
<br>&gt;     
<br>&gt;         CLASS_NAME: &quot;OpenLayers.Control.ScaleLine&quot;
<br>&gt;     }
<br>&gt; 
<br>&gt; 
<br>&gt; 
<br>&gt; 
<br>&gt; 
</div></div></div><div class="im">&gt; On Thu, Mar 24, 2011 at 3:03 PM, mickal &lt;<a href="http://user/SendEmail.jtp?type=node&amp;node=6205740&amp;i=0&amp;by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a>&gt; wrote:
<div class='shrinkable-quote'><br>&gt; Hi,
<br>&gt; 
<br>&gt; The scale that the module displayed to me is not right, I mean :
<br>&gt; 
<br>&gt; 50 pixel =&gt; 1000km
<br>&gt; but in reality :
<br>&gt; 50 pixel =&gt; 100 m
<br>&gt; 
<br>&gt; is it possible to add a coefficient to this module ?  to adjust the scale
<br>&gt; that it displayed.
<br>&gt; 
<br>&gt; 
<br>&gt; Because otherwise I have to change my map, and this process is very long.
<br>&gt; 
<br>&gt; 
<br>&gt; thx,
<br>&gt; 
<br>&gt; --
<br>&gt; View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6204219.html?by-user=t&by-user=t" rel="nofollow" link="external" target="_blank">http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6204219.html</a></div>
&gt; Sent from the OpenLayers Users mailing list archive at Nabble.com.
<br>&gt; _______________________________________________
<br>&gt; Users mailing list
<br></div>&gt; <a href="http://user/SendEmail.jtp?type=node&amp;node=6205740&amp;i=1&amp;by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><div class="im">&gt; <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>&gt; 
<br></div>&gt; _______________________________________________
<br>&gt; Users mailing list
<br>&gt; <a href="http://user/SendEmail.jtp?type=node&amp;node=6205740&amp;i=2&amp;by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><div class="im">&gt; <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a></div></div><br><div class="im">
-- 
<br>Andreas Hocevar
<br>OpenGeo - <a href="http://opengeo.org/" rel="nofollow" link="external" target="_blank">http://opengeo.org/</a><br>Expert service straight from the developers.
<br><br></div>_______________________________________________
<br>Users mailing list
<br><a href="http://user/SendEmail.jtp?type=node&amp;node=6205740&amp;i=3&amp;by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a>
<br><div class="im"><a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" rel="nofollow" link="external" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>
        
        <br>
        <br>
        </div><hr noshade size="1" color="#cccccc">
        <div style="color:#444;font:12px tahoma,geneva,helvetica,arial,sans-serif">
                <div style="font-weight:bold">If you reply to this email, your message will be added to the discussion below:</div>
                <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6205740.html?by-user=t" target="_blank" rel="nofollow" link="external">http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6205740.html</a>
        </div>
        <div style="color:#666;font:11px tahoma,geneva,helvetica,arial,sans-serif;margin-top:.4em">
                
                
        </div></blockquote></div><br>

        
<br/><hr align="left" width="300" />
View this message in context: <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6208637.html">Re: OpenLayers.Control.ScaleLine : Add a coefficient</a><br/>
Sent from the <a href="http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Users-f1822463.html">OpenLayers Users mailing list archive</a> at Nabble.com.<br/>