lab5

In lab 5, we need to update a repository, which shows you bridges locate in Ontario. Here is repository link: (https://github.com/humphd/bridge-troll). We need to add the feature to switch night and day.

Before we change and debug the code, we need to install suncalc.SunCalc is a tiny BSD-licensed JavaScript library for calculating sun position, sunlight phases (times for sunrise, sunset, dusk, etc.), moon position and lunar phase for the given location and time. More details about suncalc on this link:(https://github.com/mourner/suncalc). Typing   ”npm install suncalc” in terminal to install that.

The another thing is finding the map themes based on library Leaflet (http://leafletjs.com/).

Next, I gonna fix the code.

I import the module in map.js

module

 

Then we need change the code to implement the feature. Here is the code what I fix and change.

change

Next, run it and copy the localhost.

It is day.

day

It is night map.

dark

It works.

Leave a comment