I really would like that it was simple !<br><br>But it'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"><<a href="/user/SendEmail.jtp?type=node&node=6208637&i=0&by-user=t" target="_top" rel="nofollow" link="external">[hidden email]</a>></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't match the projection's distance units.
<br><br>I'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>> 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>>         • float calculateTheCoefficient(float length, int pixels ); // length in meter , pixels number of pixels that the length represent
<br>>         • void setTheCoefficient ( float k );
<br>>
<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>> update: function() {
<br>> var res = this.map.getResolution();
<br>> res*= k;
<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>> }
<br>>
<br>>
<br>>
<br>>
<br>>
</div></div></div><div class="im">> On Thu, Mar 24, 2011 at 3:03 PM, mickal <<a href="http://user/SendEmail.jtp?type=node&node=6205740&i=0&by-user=t" rel="nofollow" link="external" target="_blank">[hidden email]</a>> wrote:
<div class='shrinkable-quote'><br>> 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>>
<br>> --
<br>> 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>
> Sent from the OpenLayers Users mailing list archive at Nabble.com.
<br>> _______________________________________________
<br>> Users mailing list
<br></div>> <a href="http://user/SendEmail.jtp?type=node&node=6205740&i=1&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></div>> _______________________________________________
<br>> Users mailing list
<br>> <a href="http://user/SendEmail.jtp?type=node&node=6205740&i=2&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></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&node=6205740&i=3&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/>