Overview

To start retrieving location information, you need to create a location watch by calling $ref:location.watchLocation, passing in the location watch details via the requestInfo parameter:

chrome.location.watchLocation(name, requestInfo);

You also need to add a listener for the $ref:location.onLocationUpdate event. Chrome will fire this event after you create your location watch, and it will keep firing the event every time the geographic location of the host machine changes, until you call $ref:location.clearWatch.

Here's sample code to listen for location updates:

  chrome.location.onLocationUpdate.addListener(function(position) {
    console.log(JSON.stringify(position));
  });