Properties Methods Events Config Options Direct Link
Observable
  GeoLocation

Class Ext.util.GeoLocation

Package:Ext.util
Defined In:GeoLocation.js
Class:GeoLocation
Extends:Observable
Provides a cross browser class for retrieving location information.

Based on the Geolocation API Specification.
If the browser does not implement that specification (Internet Explorer 6-8), it can fallback on Google Gears as long as the browser has it installed, and the following javascript file from google is included on the page:
<script type="text/javascript" src="http://code.google.com/apis/gears/gears_init.js"></script>

Note: Location implementations are only required to return timestamp, longitude, latitude, and accuracy.
Other properties (altitude, altitudeAccuracy, heading, speed) can be null or sporadically returned.

When instantiated, by default this class immediately begins tracking location information, firing a locationupdate event when new location information is available. To disable this location tracking (which may be battery intensive on mobile devices), set autoUpdate to false.
When this is done, only calls to updateLocation will trigger a location retrieval.

A locationerror event is raised when an error occurs retrieving the location, either due to a user denying the application access to it, or the browser not supporting it.

The below code shows a GeoLocation making a single retrieval of location information.
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

Config OptionsDefined By

Public Properties

PropertyDefined By
 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
 timestamp : Date
Read-only property representing when the last retrieved positioning information was acquired by the device.
GeoLocation

Public Methods

MethodDefined By

Public Events

EventDefined By