Page 1 of 1

Icons for wind direction

Posted: Fri 22 Apr 2016 11:01 pm
by Mapantz
Hello folks..

I've just managed to implement some icons to show the temp/pressure trends - from reading the posts on this forum. :)

I was just about to do the wind direction icons as well, then something occurred to me! I use <span id="wdir"> on my main page, instead of #wdir as I'm using the realtimereader.js to update some of the values at 10 second intervals. I'm now stuck (lack of coding knowledge)

This is obviously what would have been used:

Code: Select all

<img src="images/<#wdir>.png" alt="Wind is coming from the <#wdir>" title="Wind is coming from the <#wdir>" />
Is there a way to implement <span id="wdir"> so it uses the icons, and update at the interval I use?

Many thanks.

Re: Icons for wind direction

Posted: Sun 24 Apr 2016 9:23 pm
by mcrossley
I'm not sure what you want to do here. Do you mean you want to use icons from a font file? Maybe icons combined into a sprite file?

You have two approaches...

1. Use a separate image for each direction you want to show (maybe 16 for the cardinal points?). This could be achieved with an <image> tag, or using an icon font and displaying the appropriate character, or using all the icons combined into a single sprite file and displaying what you with css.

2. Use a single image and rotate it using CSS.

Normally you keep the 'id' of the tag you are manipulating constant (so you always know what is called and how to refer to it) and change the properties by altering the style (either directly, or by using predefined classes).

Re: Icons for wind direction

Posted: Mon 25 Apr 2016 7:17 am
by jdc
You could use "<#avgbearing> " or "<#bearing>" which is 1-360 for rotation but still display "<#wdir>" as text.