Rendering the map

The third feature is to about rendering the map in the view. To implement this feature, we will:

  • Retrieve user location from the browser
  • Create a custom binding handler for maps panel
  • Update the view to display the map

Let's start by creating a method to retrieve the user location form the browser. The current user location information will be used to initialize the map. We will use the getCurrentPosition method of the Geolocation class provided by the browser to get the user's current location.

Tip

The Geolocation class provides methods to obtain the location of the device. The location information can be used to provide a customized experience to the user. The API reference for Geolocation class can be found at https://developer.mozilla.org/en-US/docs/Web/API/Geolocation ...

Get KnockoutJS by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.