August 2017
Beginner
298 pages
7h 4m
English
Before we start building the widget, let's take a look at the steps to retrieve the user's geolocation. In your src/js/home.js file, you should see an import statement, which will import the CSS into the web application. Below that import statement, add the following code:
window.addEventListener('load', () => { getLocation();});function getLocation() {}This will call the getLocation() function when the page completes loading. Inside this function, we must first check whether the navigator.geolocation method is available in the browser. If it is available, we can use the navigator.geolocation.getCurrentPosition() method to retrieve the user's geolocation. This method accepts two functions as parameters. The first ...
Read now
Unlock full access