[OpenLayers-Dev] Design for scale-line

Ian Mayo ian at planetmayo.com
Mon Oct 8 16:01:12 EDT 2007


thanks again for the feedback, comments below...

On 05/10/2007, Paul Spencer <pspencer at dmsolutions.ca> wrote:
> 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.

Have set Eclipse/Aptana to always use spaces - hopefully it will now
be consistent.

> 2) you do not seem to be accommodating the current units of the map -
> I use different projections, often in meters.  From the docs:
>
> So you need to check to see what map.units is before converting

Sorted (easy)...

> 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);

Ooh Paul, you couldn't just point me to where/how I need to switch my
algorithm to accommodate this?  Is it right at the start when I
convert the maxSizePx in pixels to data units?

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

Aaah.  I made the change to reflect the current data units, and the
spherical mercator example appears to work fine (within my limited
understanding of the problem domain...).

> Cheers
> Paul

thanks again,
Ian.



More information about the Dev mailing list