[OpenLayers-Users] Re: OpenLayers.Control.ScaleLine : Add a
coefficient
mickal
mickamusset at gmail.com
Fri Mar 25 14:04:20 EDT 2011
I really would like that it was simple !
But it's not, the map is come from a dxf file ( dxf2shp with qgis ).
So the scale is not respected.
Thx,
On Thu, Mar 24, 2011 at 10:35 PM, Andreas Hocevar-2 [via OSGeo.org] <
ml-node+6205740-1095475097-182549 at n2.nabble.com> wrote:
> 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.
>
> 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.
>
> Regards,
> Andreas.
>
> On Mar 24, 2011, at 19:03 , Micka wrote:
>
> > Hey,
> >
> >
> > Well, I've gotten the source code of this module, so now i'm trying to
> add a coeficient K .
> >
> >
> > The goal is to give the possibility to adjust the scaleline.
> >
> > For that, I thought that we can add two function on this module :
> >
> > • float calculateTheCoefficient(float length, int pixels ); //
> length in meter , pixels number of pixels that the length represent
> > • void setTheCoefficient ( float k );
> >
> > The first function will calculate the coefficient with the actual
> resolution and the length/pixels .
> > the second function will save the coefficient for the update function() .
>
> >
> >
> > What do you think ?
> >
> >
> > My problem, is that i don't know how to do code the first function
> .......
> >
> >
> >
> >
> >
> >
> > update: function() {
> > var res = this.map.getResolution();
> > res*= k;
> > if (!res) {
> > return;
> > }
> >
> > // convert maxWidth to map units
> > var maxSizeData = this.maxWidth * res;
> >
> > // decide whether to use large or small scale units
> > var topUnits;
> > if(maxSizeData > 0.1) {
> > topUnits = this.topOutUnits;
> > } else {
> > topUnits = this.topInUnits;
> > }
> >
> > // and to map units units
> > var curMapUnits = this.map.units;
> > var inches = OpenLayers.INCHES_PER_UNIT;
> > var topMax = maxSizeData * inches[curMapUnits] /
> inches[topUnits];
> >
> > // now trim this down to useful block length
> > var topRounded = this.getBarLen(topMax);
> >
> > // and back to display units
> > topMax = topRounded / inches[curMapUnits] * inches[topUnits];
>
> >
> > // and to pixel units
> > var topPx = topMax / res;
> >
> > // now set the pixel widths
> > this.eTop.style.width = Math.round(topPx) + "px";
> >
> > // and the values inside them
> > this.eTop.innerHTML = topRounded + " " + topUnits;
> > },
> >
> > CLASS_NAME: "OpenLayers.Control.ScaleLine"
> > }
> >
> >
> >
> >
> >
> > On Thu, Mar 24, 2011 at 3:03 PM, mickal <[hidden email]<http://user/SendEmail.jtp?type=node&node=6205740&i=0&by-user=t>>
> wrote:
> > Hi,
> >
> > The scale that the module displayed to me is not right, I mean :
> >
> > 50 pixel => 1000km
> > but in reality :
> > 50 pixel => 100 m
> >
> > is it possible to add a coefficient to this module ? to adjust the scale
>
> > that it displayed.
> >
> >
> > Because otherwise I have to change my map, and this process is very long.
>
> >
> >
> > thx,
> >
> > --
> > View this message in context:
> http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6204219.html<http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6204219.html?by-user=t>
> > Sent from the OpenLayers Users mailing list archive at Nabble.com.
> > _______________________________________________
> > Users mailing list
> > [hidden email]<http://user/SendEmail.jtp?type=node&node=6205740&i=1&by-user=t>
> > http://lists.osgeo.org/mailman/listinfo/openlayers-users
> >
> > _______________________________________________
> > Users mailing list
> > [hidden email]<http://user/SendEmail.jtp?type=node&node=6205740&i=2&by-user=t>
> > http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
> --
> Andreas Hocevar
> OpenGeo - http://opengeo.org/
> Expert service straight from the developers.
>
> _______________________________________________
> Users mailing list
> [hidden email]<http://user/SendEmail.jtp?type=node&node=6205740&i=3&by-user=t>
> http://lists.osgeo.org/mailman/listinfo/openlayers-users
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6205740.html
> To unsubscribe from OpenLayers.Control.ScaleLine : Add a coefficient, click
> here<http://osgeo-org.1803224.n2.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=6204219&code=bWlja2FtdXNzZXRAZ21haWwuY29tfDYyMDQyMTl8LTY5MzgyMTU0NQ==>.
>
>
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/OpenLayers-Control-ScaleLine-Add-a-coefficient-tp6204219p6208637.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20110325/45dff89d/attachment-0003.html
More information about the Users
mailing list