[OpenLayers-Dev] Design for scale-line
Ian Mayo
ian at planetmayo.com
Tue Oct 2 15:52:23 EDT 2007
Here's the design for my OpenLayers scale control, aimed to offer
similar functionality to the scale offered in google maps.
The new control is to be called "ScaleLine". Yes, there's lots of
room for improvement there, suggestions welcome.
Here are the steps I'll take:
1. Determine current scale
2. Determine width of view in metres
3. Determine how wide 10% of view is in metres
4. Round width up/down to nearest "round number" in increasing size of units:
-- 1,2,5,10,20,50,100,200,500 (metres)
-- 1,2,5,10,20,50,100,200,500,1000,2000 (km)
5. Calculate size of line of rounded length in screen units
6. Draw line of scaled length, with text-label on right-hand size into
'div' for this control
7. Repeat the above for imperial units
The Div will have been located using the css-style called .olControlScaleLine
Questions from me?
Well, yes. I've seen from the other controls how to draw plain text
onto the map. Drawing my graphic is a little more complex. Should
the line and "tails" be an OpenLayer feature? Or is there another
method for drawing line-based items. I suppose I could have a div
with left, bottom, right borders - with the div-width set to the width
in step 5 above.
Any advice?
thanks in advance for any support,
Ian.
p.s. Should I have written this content into a wiki page? Opinions welcome.
More information about the Dev
mailing list