What better way to spend the first day of June, which coincidentally is my birthday, talking about the weather which here in the UK is undoubtedly the top ice-breaker to strike a conversation.
For over a year now I’ve been publishing short posts to my website and syndicating them out to Twitter. In an ongoing attempt to offer up more of the features, information and user experience common social networks offer; I recently decided to add my own geolocation functionality into my hand-rolled CMS and from that the option to display local weather information too.
Getting my location
Handling geolocation data
Having stored the geolocation data I then output this on my website. I should note at this point that I haven’t gone the full way in terms of backwards processing the longitude/latitude values in to obtain the name of the place I’m posting from. My main aim at this point was to create the means to post weather information so for the time being I simply output these values into a URL which takes the user directly to Open Street Maps detailing where I’ve posted from.
Finding a weather API
Unlike geolocation it’s beyond the possibility that weather information can be served up from built-in web browser functionality. Hence the need to source a reliable data source for live weather information. Thankfully there are some APIs now available to do this however not all are delivered of HTTPS so if your website has an SSL certificate you’ll need to find one which is.
Storing weather data
How this works within my CMS editor is that I first get my location and depending on whether that’s successful or not then I get the options to obtain the weather data below.
Displaying weather on my posts
On the front-end I output the stored weather data from my CMS with some simple SVG graphics I designed corresponding to the names of the weather conditions stored.
So there you have it, a quick run through of posting location-based weather conditions on a per-post basis. I hope to enhance the geolocation side of things soon but keeping such additional post data within limits so not to distract readers from the content, because as they say: content is King!