Implementing Day/Night Mode in bridge-troll

For this lab we were to contribute to the bridge-troll app and fix the issue-6.  This issue was the map didn't have a day/night feature.  This means while its dark outside the map would stay the same as it is during the day time which is very bright.

Initially while working on the app it was very hard to get it working on a Windows environment. Due to this I had to use a Linux machine to fix the issue. As I was looking at solutions on how to get started on fixing the bug, I saw that in the issue description itself there was pretty much a solution given.

This solution was to use suncalc which is an application that calculates the suns position and determines whether its dark or not.  This helped in figuring out the issue of what time the map should switch to the darker colored mode. The implementation of this code was fairly simple the below screenshots show the code added that checks the time.

After checking the time the changing of the map was very simple.  I just a different tile provided by Leaflet called CartoDB.DarkMatter.  Below is the code that I added that changed the map accordingly.


In the end, after adding all the above code, the final result was the following at different times.

Comments

Popular posts from this blog

Assignment 1 - DPS909

ECMA Script Testing

Release 0.2 - Bug fix