/gist:821df370e6c019d58cc9 Secret
Last active
August 29, 2015 14:01
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just the new parts for the interface exposed on navigator.geolocation. | |
// In addition there will be two more events, 'regionenter' and 'regionexit'. | |
interface Geolocation : EventTarget { | |
// Registers a Region. If a Region with the same ID has already been | |
// registered the new region will override it. | |
// | |
// The Promise is called with success when the region was successfully | |
// registered, rejected on failure. Possible failure reasons include the | |
// user not accepting the location request, or the Region being invalid. | |
Promise<void> registerRegion(Region region); | |
// Deregisters a Region. The Promise is called with success when the region | |
// was succesfully deregistered, rejected on failure. Possible failure | |
// reasons include a Region with the given ID not existing. | |
Promise<void> deregisterRegion(DOMString regionId); | |
// Returns all registered Regions. Note that regions may automatically be | |
// unregistered; for example, users may revoke, or the device may choose | |
// to forget them (in particular on device restart). | |
// | |
// The Promise is called with the list of Regions on success (which may be | |
// empty), rejected on failure to get regions. Possible failure reasons | |
// are up to the imagination, but do *not* necessarily include simply | |
// having no registered Regions. | |
Promise<Region[]> getRegisteredRegions(); | |
}; | |
interface Region { | |
// All regions may be referred to by a string identifier. Exactly one Region | |
// can be registered per identifier. | |
readonly attribute DOMString id; | |
}; | |
// Constructor argument for a CircularRegion. | |
dictionary CircularRegionInit { | |
DOMString id; | |
double latitude; | |
double longitude; | |
double radius; | |
}; | |
[Constructor(CircularRegionInit init)] | |
interface CircularRegion : Region { | |
// TODO(kalman): Is this how to declare these? | |
readonly static attribute double MIN_RADIUS; | |
readonly static attribute double MAX_RADIUS; | |
// Latitude in degrees, between -90 and +90 inclusive. | |
readonly attribute double latitude; | |
// Longitude in degree, between -180 and +180 inclusive. | |
readonly attribute double longitude; | |
// Radius of the region in meters. Must be in the range [MIN_RADIUS, | |
// MAX_RADIUS], values are platform dependent. | |
readonly attribute double radius; | |
}; | |
// Constructor argument for a BluetoothLowEnergyRegion. | |
dictionary BluetoothLowEnergyRegionInit { | |
DOMString[] uuids; | |
double radius; | |
}; | |
[Constructor(BluetoothLowEnergyRegionInit init)] | |
interface BluetoothLowEnergyRegion : Region { | |
// TODO(kalman): Is this how to declare these? | |
readonly static attribute double MIN_RADIUS; | |
readonly static attribute double MAX_RADIUS; | |
// TODO(kalman): Do we need some sort of accuracy constant? | |
// List of BLE UUIDs. If any UUID is matched then this region is | |
// considered to be entered. | |
DOMString[] uuids; | |
// Radius. Likely to be a rough estimate. | |
double radius; | |
}; | |
// Registered as 'regionenter' on the Geolocation object. | |
// Fired when a registered region is entered. | |
interface RegionEnterEvent : Event { | |
readonly attribute Region region; | |
}; | |
// Registered as 'regionexit' on the Geolocation object. | |
// Fired when a registered region is exited. | |
interface RegionExitEvent : Event { | |
readonly attribute Region region; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment