Skip to content

Instantly share code, notes, and snippets.

@mkruisselbrink
Last active August 29, 2015 14:04
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mkruisselbrink/b68110599a986bb9c963 to your computer and use it in GitHub Desktop.
[exposed=Window&Worker]
partial interface Navigator {
readonly attribute Geofencing geofencing;
};
partial interface ServiceWorkerGlobalScope
{
attribute EventHandler ongeofenceenter;
attribute EventHandler ongeofenceleave;
};
[NoInterfaceObject]
interface GeofencingEvent {
readonly attribute GeofencingRegion region;
readonly attribute Position position;
}
[NoInterfaceObject]
interface Geofencing {
Promise<undefined> registerRegion(GeofencingRegion region);
Promise<undefined> unregisterRegion(DOMString regionId);
Promise<sequence<GeofencingRegion>> getRegisteredRegions();
Promise<GeofencingRegionState> getRegionState(DOMString regionId);
};
dictionary GeofencingRegionState {
readonly attribute GeofencingRegion region;
readonly attribute DOMString state; // "inside", "outside"
};
[NoInterfaceObject]
interface GeofencingRegion {
readonly attribute DOMString id;
};
dictionary GeolocationPoint {
double latitude;
double longitude;
double? altitude;
};
[Constructor(optional String? id, dictionary options), exposed=Window&Worker]
interface CircularRegion : GeofencingRegion {
const double MIN_RADIUS = 10;
const double MAX_RADIUS = 1000;
readonly attribute GeolocationPoint center;
readonly attribute double radius;
};
// Other potential region types:
// Polygon of nonintersecting line segments.
[Constructor(optional String? id, dictionary options), exposed=Window&Worker]
interface PolygonRegion : GeofencingRegion {
readonly attribute sequence<GeolocationPoint> points;
};
// A region centered around whatever the current location of the device is
[Constructor(optional String? id, dictionary options), exposed=Window&Worker]
interface CurrentLocationRegion : GeofencingRegion {
readonly attribute double radius;
};
// Show some UI to let the user select a region. Not sure if this makes sense,
// and not sure what the use case would be.
[Constructor(optional String? id), exposed=Window&Worker]
interface UserSelectedRegion : GeofencingRegion {
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment