w3c / geofencing-api

13 stars 9 forks source link

Uncaught (in promise) ReferenceError: CircularGeofenceRegion is not defined #27

Closed ghost closed 5 years ago

ghost commented 8 years ago

Hi maybe it's me but I am getting this error with the example on w3C and on our test script, I will give you the script where the error is coming from with the w3C example:

// https://example.com/webapp.js
navigator.serviceWorker
  .register('serviceworker.js')
  .then((swRegistration) => {
    let region = new CircularGeofenceRegion({
      name: 'myfence',
      latitude: 37.421999,
      longitude: -122.084015,
      radius: 1000
    });
    let options = {
      includePosition: true
    };
    swRegistration.geofencing.add(region, options)
      .then(
        // If more than just a name needs to be stored with a geofence, now
        // would be the time to store this in some storage.
        (geofence) => console.log(geofence.id),
        (error) => console.log(error)
      );
  });

I am getting this error in Google Canary Version 52.0.2727.0 canary (64-bit).

I hope someone can help as very keen to combine geofencing to my service worker script. Dreamweaver and Canary are pointing to this line:

.then((swRegistration) => {
    let region = new CircularGeofenceRegion({
      name: 'myfence',
      latitude: 37.421999,
      longitude: -122.084015,
      radius: 1000
    });

But I really can't see what's the problem? (so I thought I'd ask)

ghost commented 8 years ago

Going to add my script as well, again getting same error msg in Google Canary. My code is here:

navigator.serviceWorker.ready.then(function(serviceWorkerRegistration) {
  var region = new CircularGeofenceRegion("myfence", 37.421999, -122.084015, 1000);
  serviceWorkerRegistration.geofencing.add(region).then(function(regionRegistration) {
    console.log("Created Geofence " + regionRegistration);
  }, function(error) {
    console.log("Error: " + error);
  });
});
jyasskin commented 8 years ago

Right, it's not implemented in Chrome yet. http://caniuse.com/ will get an entry for geofencing when it's been implemented somewhere.

ghost commented 8 years ago

Thanks for the reply. Will wait for implementation.