[OpenLayers-Dev] Design for scale-line

Paul Spencer pspencer at dmsolutions.ca
Fri Oct 5 16:47:21 EDT 2007


Hi Ian,

looks like nicely written code :)  I'm sure this will be very useful  
to have as a Control in OpenLayers.  I have a few comments:

1) you have a problem with tabs vs spaces in code formatting that  
made my eyes wonky in a couple of places.

2) you do not seem to be accommodating the current units of the map -  
I use different projections, often in meters.  From the docs:

units

{String} The map units.  Defaults to ‘degrees’.  Possible values are  
‘degrees’ (or ‘dd’), ‘m’, ‘ft’, ‘km’, ‘mi’, ‘inches’.

So you need to check to see what map.units is before converting

3) If the units are decimal degrees, you should adjust the  
calculation based on the current latitude of the center using the  
cosine of the latitude.  This was from a distance measuring tool I  
did a while back:

d = d * Math.cos(2 * Math.PI * map.center.lat / 360);

4) you will need to accomodate the spherical mercator stuff too ...  
loads of people use that

Cheers

Paul

On 5-Oct-07, at 10:22 AM, Ian Mayo wrote:

> Hi all, I have a working demonstrator at:
> http://dev.openlayers.org/sandbox/ianmayo/openlayers/examples/ 
> controls.html
>
> At the top-right of the plot you'll see the current scale represented
> as a bar.  As far as I can see, the implementation seems sound - I
> just have to polish off the unit tests (the earlier tests were more
> associated with me learning how the scaling works).
>
> Aaah, and yes, please break it & report as appropriate.  I'd also
> appreciate hearing what configurable options people may want.
> Currently we have m/km on the top and ft/mi on the bottom - switching
> between the correct set to use depending on how far we've zoomed in.
> Does anybody want to be able to configure to use other units?
>
> Ian.
>
> On 02/10/2007, Ian Mayo <ian at planetmayo.com> wrote:
>> Here's the design for my OpenLayers scale control, aimed to offer
>> similar functionality to the scale offered in google maps.
>> Any advice?
>>
>> thanks in advance for any support,
>> Ian.
>>
>> p.s.  Should I have written this content into a wiki page?   
>> Opinions welcome.
>>
> _______________________________________________
> Dev mailing list
> Dev at openlayers.org
> http://openlayers.org/mailman/listinfo/dev

+-----------------------------------------------------------------+
|Paul Spencer                          pspencer at dmsolutions.ca    |
+-----------------------------------------------------------------+
|Chief Technology Officer                                         |
|DM Solutions Group Inc                http://www.dmsolutions.ca/ |
+-----------------------------------------------------------------+








More information about the Dev mailing list