Observable GeoLocation
Package: | Ext.util |
Defined In: | GeoLocation.js |
Class: | GeoLocation |
Extends: | Observable |
<script type="text/javascript" src="http://code.google.com/apis/gears/gears_init.js"></script>
var geo = new Ext.util.GeoLocation({
autoUpdate: false,
listeners: {
locationupdate: function (geo) {
alert('New latitude: ' + geo.latitude);
},
locationerror: function ( geo,
bTimeout,
bPermissionDenied,
bLocationUnavailable,
message) {
if(bTimeout){
alert('Timeout occurred.');
}
else{
alert('Error occurred.');
}
}
}
});
geo.updateLocation();
Config Options | Defined By | |
---|---|---|
allowHighAccuracy : Boolean Defaults to false.
When set to true, provide a hint that the application would like to receive
the best possible res... Defaults to false. When set to true, provide a hint that the application would like to receive the best possible results. This may result in slower response times or increased power consumption. The user might also deny this capability, or the device might not be able to provide more accurate results than if this option was set to false. | GeoLocation | |
autoUpdate : Boolean Defaults to true.
When set to true, continually monitor the location of the device
(beginning immediately) and fire l... Defaults to true. When set to true, continually monitor the location of the device (beginning immediately) and fire locationupdate/locationerror events. When using google gears, if the user denies access or another error occurs, this will be reset to false. | GeoLocation | |
listeners : Object A config object containing one or more event handlers to be added to this
object during initialization. This should ... A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the addListener example for attaching multiple handlers at once. DOM events from ExtJs Components While some ExtJs Component classes export selected DOM events (e.g. "click", "mouseover" etc), this
is usually only done when extra value can be added. For example the DataView's
| Observable | |
maximumAge : Number Defaults to 0.
This option indicates that the application is willing to accept cached location information whose age ... Defaults to 0. This option indicates that the application is willing to accept cached location information whose age is no greater than the specified time in milliseconds. If maximumAge is set to 0, an attempt to retrieve new location information is made immediately. Setting the maximumAge to Infinity returns a cached position regardless of its age. If the device does not have cached location information available whose age is no greater than the specified maximumAge, then it must acquire new location information. For example, if location information no older than 10 minutes is required, set this property to 600000. | GeoLocation | |
timeout : Number Defaults to Infinity.
The maximum number of milliseconds allowed to elapse between a location update operation
and th... Defaults to Infinity. The maximum number of milliseconds allowed to elapse between a location update operation and the corresponding locationupdate event being raised. If a location was not successfully acquired before the given timeout elapses (and no other internal errors have occurred in this interval), then a locationerror event will be raised indicating a timeout as the cause. Note that the time that is spent obtaining the user permission is not included in the period covered by the timeout. The timeout attribute only applies to the location acquisition operation. In the case of calling updateLocation, the locationerror event will be raised only once. If autoUpdate is set to true, the locationerror event could be raised repeatedly. The first timeout is relative to the moment autoUpdate was set to true (or this Ext.util.GeoLocation was initialized with the autoUpdate config option set to true). Subsequent timeouts are relative to the moment when the device determines that it's position has changed. | GeoLocation |
Property | Defined By | |
---|---|---|
accuracy : Number Read-only property representing the last retrieved
accuracy level of the latitude and longitude coordinates,
specif... Read-only property representing the last retrieved
accuracy level of the latitude and longitude coordinates,
specified in meters. This will always be a non-negative number. This corresponds to a 95% confidence level. | GeoLocation | |
altitude : Number/null Read-only property representing the last retrieved
height of the position, specified in meters above the ellipsoid
<... Read-only property representing the last retrieved
height of the position, specified in meters above the ellipsoid
[WGS84]. | GeoLocation | |
altitudeAccuracy : Number/null Read-only property representing the last retrieved
accuracy level of the altitude coordinate, specified in meters.
I... Read-only property representing the last retrieved
accuracy level of the altitude coordinate, specified in meters. If altitude is not null then this will be a non-negative number. Otherwise this returns null. This corresponds to a 95% confidence level. | GeoLocation | |
heading : Number/null Read-only property representing the last retrieved
direction of travel of the hosting device,
specified in non-nega... Read-only property representing the last retrieved
direction of travel of the hosting device,
specified in non-negative degrees between 0 and 359,
counting clockwise relative to the true north. If speed is 0 (device is stationary), then this returns NaN | GeoLocation | |
latitude : Number Read-only property representing the last retrieved
geographical coordinate specified in degrees. | GeoLocation | |
longitude : Number Read-only property representing the last retrieved
geographical coordinate specified in degrees. | GeoLocation | |
speed : Number/null Read-only property representing the last retrieved
current ground speed of the device, specified in meters per secon... Read-only property representing the last retrieved
current ground speed of the device, specified in meters per second. If this feature is unsupported by the device, this returns null. If the device is stationary, this returns 0, otherwise it returns a non-negative number. | GeoLocation | |
timestamp : Date Read-only property representing when the last retrieved
positioning information was acquired by the device. | GeoLocation |
Method | Defined By | |
---|---|---|
addEvents( Object|String o , string Optional. )
:
voidAdds the specified events to the list of events which this Observable may fire. Adds the specified events to the list of events which this Observable may fire. Parameters:
| Observable | |
addListener( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object. Appends an event handler to this object. Parameters:
| Observable | |
addManagedListener( Observable|Element item , Object|String ename , Function fn , Object scope , Object opt )
:
voidAdds listeners to any Observable object (or Element) which are automatically removed when this Component
is destroyed... Adds listeners to any Observable object (or Element) which are automatically removed when this Component is destroyed. Parameters:
| Observable | |
clearListeners()
:
void Removes all listeners for this object including the managed listeners Removes all listeners for this object including the managed listeners Parameters:
| Observable | |
clearManagedListeners()
:
void Removes all managed listeners for this object. Removes all managed listeners for this object. Parameters:
| Observable | |
enableBubble( String/Array events )
:
voidEnables events fired by this Observable to bubble up an owner hierarchy by calling
this.getBubbleTarget() if present.... Enables events fired by this Observable to bubble up an owner hierarchy by calling
This is commonly used by Ext.Components to bubble events to owner Containers. See Ext.Component.getBubbleTarget. The default implementation in Ext.Component returns the Component's immediate owner. But if a known target is required, this can be overridden to access the required target more quickly. Example:
Parameters:
| Observable | |
fireEvent( String eventName , Object... args )
:
BooleanFires the specified event with the passed parameters (minus the event name).
An event may be set to bubble up an Obse... Fires the specified event with the passed parameters (minus the event name). An event may be set to bubble up an Observable parent hierarchy (See Ext.Component.getBubbleTarget) by calling enableBubble. Parameters:
| Observable | |
hasListener( String eventName )
:
BooleanChecks to see if this object has any listeners for a specified event Checks to see if this object has any listeners for a specified event Parameters:
| Observable | |
on( String eventName , Function handler , [Object scope ], [Object options ] )
:
voidAppends an event handler to this object (shorthand for addListener.) Appends an event handler to this object (shorthand for addListener.) Parameters:
| Observable | |
relayEvents( Object o , Array events )
:
voidRelays selected events from the specified Observable as if the events were fired by this. Relays selected events from the specified Observable as if the events were fired by this. Parameters:
| Observable | |
removeListener( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler. Removes an event handler. Parameters:
| Observable | |
removeManagedListener( Observable|Element item , Object|String ename , Function fn , Object scope )
:
voidRemoves listeners that were added by the mon method. Removes listeners that were added by the mon method. Parameters:
| Observable | |
resumeEvents()
:
void Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
event... Resume firing events. (see suspendEvents)
If events were suspended using the queueSuspended parameter, then all
events fired during event suspension will be sent to any listeners now. Parameters:
| Observable | |
setAllowHighAccuracy( Number allowHighAccuracy )
:
voidChanges the allowHighAccuracy option and restarts any active
location monitoring with the updated setting. Changes the allowHighAccuracy option and restarts any active
location monitoring with the updated setting. Parameters:
| GeoLocation | |
setAutoUpdate( Boolean autoUpdate )
:
BooleanEnabled/disables the auto-retrieval of the location information.
If called with autoUpdate=true, it will execute an i... Enabled/disables the auto-retrieval of the location information. If called with autoUpdate=true, it will execute an immediate location update and continue monitoring for location updates. If autoUpdate=false, any current location change monitoring will be disabled. Parameters:
| GeoLocation | |
setMaximumAge( Number maximumAge )
:
voidChanges the maximumAge option and restarts any active
location monitoring with the updated setting. Changes the maximumAge option and restarts any active
location monitoring with the updated setting. Parameters:
| GeoLocation | |
setTimeout( Number timeout )
:
voidChanges the timeout option and restarts any active
location monitoring with the updated setting. Changes the timeout option and restarts any active
location monitoring with the updated setting. Parameters:
| GeoLocation | |
suspendEvents( Boolean queueSuspended )
:
voidSuspend the firing of all events. (see resumeEvents) Suspend the firing of all events. (see resumeEvents) Parameters:
| Observable | |
un( String eventName , Function handler , [Object scope ] )
:
voidRemoves an event handler (shorthand for removeListener.) Removes an event handler (shorthand for removeListener.) Parameters:
| Observable | |
updateLocation( Function callback , [Object scope ] )
:
voidExecutes a onetime location update operation,
raising either a locationupdate or locationerror event.
Does not inter... Executes a onetime location update operation,
raising either a locationupdate or locationerror event. Does not interfere with or restart ongoing location monitoring. Parameters:
| GeoLocation |
Event | Defined By | |
---|---|---|
locationerror :
( Ext.util.GeoLocation this , Boolean timeout , Boolean permissionDenied , Boolean locationUnavailable , String message )
Raised when a location retrieval operation failed.
In the case of calling updateLocation, this event will be raised o... Raised when a location retrieval operation failed. In the case of calling updateLocation, this event will be raised only once. If autoUpdate is set to true, this event could be raised repeatedly. The first error is relative to the moment autoUpdate was set to true (or this Ext.util.GeoLocation was initialized with the autoUpdate config option set to true). Subsequent errors are relative to the moment when the device determines that it's position has changed. Listeners will be called with the following arguments:
| GeoLocation | |
locationupdate :
( Ext.util.GeoLocation this )
Raised when a location retrieval operation has been completed successfully. Raised when a location retrieval operation has been completed successfully. Listeners will be called with the following arguments:
| GeoLocation |