GPS in Browser - Get GPS position from a browser using javascript
This feature in GpsGate will allow web pages to read the position from a GPS connected to your
local computer in a safe and controlled way. This opens up for very cool web applications which can become position aware.
Some example applications are to make a form that automatically includes a GPS position before it is posted
to a web server. Or a map displayed in the browser which marks out your current position.
Make sure you have GpsGate Client Express installed, and have "GPS in Browser" added as Output. You can download GpsGate here. GpsGate Client Express is free to use without time limit.
For a simple demonstration click here
For a sample that adds GPS position to a form click here
Connect a GPS to Google maps here
Requirements
You need a built in GPS or a GPS connected to your computer and GpsGate must be running.
GPS in browser works with any browser that handles javascripts.
It is tested on Internet Explorer, Firefox, Opera, Safari, and Opera Mobile on Windows Mobile / Pocket PC.
Answers to some common questions.
1. Is it safe? Which web site can access my GPS position?
Yes, it is safe. Web pages that you view in your browser can request the GPS position using Javascript.
But you as a user will always be asked to permit a certain page to do so.
2. Can I connect my GPS to a map on any site now?
No, a web page must be specially designed to take advantage of this feature. See the developer section below for more information.
3. Can I turn this feature off?
Yes, simply remove "GPS in browser" from your Outputs in GpsGate. Or exit GpsGate.
4. Can the GPS be turned on only when it is accessed by a page?
Yes, make sure "Close input on idle" (Pocket PC) or "Close input when no outputs conencted" (Windows) is selected.
With this option selected GpsGate will only activate the GPS when it is needed, this will save battery. You must select
"Show more options..." in the "Advanced" tab to see this option. By default it is turned off.
For Developers
"GPS in browser" uses cross scripting. GpsGate runs a small local web server from which your page can request
GPS information. A javascript library is included to make this really simple. Please take a look at the source
code for [url=/gpsgate/gps.html">gps.html</a> for a sample.
Simple sample on how to get GPS position into your web page.
<table border=0 bgcolor="#dddddd" width="100%">
<tr><td>
<pre>
<HTML>
<HEAD>
</HEAD>
<BODY>
<script type="text/javascript" src="http://localhost:12175/javascript/GpsGate.js"></script>
<script type="text/javascript">
//<![CDATA[
// That is the callback function that is specified in getGpsInfo() and
// executed after the data is returned
// See more info on the returned "gps" object below.
if (typeof(GpsGate) == 'undefined' || typeof(GpsGate.Client) == 'undefined')
{
alert('GpsGate not installed or not started!');
}
function gpsGateCallback(gps)
{
var resultTag = document.getElementById('position');
resultTag.innerHTML = 'longitude:' + gps.trackPoint.position.longitude +
' latitude:' + gps.trackPoint.position.latitude;
var d = new Date(gps.trackPoint.utc);
resultTag = document.getElementById('time');
resultTag.innerHTML = d.toLocaleString();
}
//]]>
</script>
<div id="position"></div>
<div id="time"></div>
<form name="f1">
<input value="GPS info" type="button"
onclick='JavaScript:GpsGate.Client.getGpsInfo(gpsGateCallback)'
id=button1 name=button1>
</form>
</BODY>
</HTML>
</pre>
</td></tr></table>
Specification of object sent to getGpsInfo() callback
You can also call getVersion() which will return the version object only.
<table border=0 bgcolor="#dddddd" width="100%">
<tr><td>
<pre>
obj
.status
// boolean - Will be true if this is a valid fix, else set to false
.valid
// boolean -Will be set to true if user permitted GPS request.
// If set to false only version information, and no other
// information is provided in this object
.permitted
// Version of GpsGate installed.
.version
// integer - Major version. For 2.5 build 233 this value is 2
.major
// integer - Minor version. For 2.5 build 233 this value is 5
.minor
// integer - Build number. For 2.5 build 233 this value is 233
.build
.trackPoint
.position
// double - Latitude in decimal degrees.
.latitude
// double - Longitude in decimal degrees
.longitude
// double - Altitude in meters
.altitude
.velocity
// double - Speed over ground in meters per second
.groundSpeed
// double - Heading in degrees. 0 is north, 90 east, 180 south, 270 west, etc.
.heading
// double - Magnetic variation in degrees
.magneticVariation
// string - Time stamp in GMT / UTC
.utc
// Quality of position
.precision
// double - HDOP
.hdop
// Satellites used for fix
.satellites
// integer - Number of satellites in items arrat
.count
// Array with information of each satellite in view
items[]
// integer - satellite ID
.prn
// integer - Signal to noice ratio
.snr
// integer - Elevation in degrees
.elevation
// integer - Azimuth in degrees
.azimuth
// boolean - true if this satellite was used to calculate position fix.
.usedForFix
</pre>
</td></tr></table>
You can optionally use this logo on a web page that supports GpsGate "GPS in Browser"
<img src="images/gpsgate_gpsinbrowser_m.gif" width=140 height=40>
More GPS Web Service from GpsGate.
GpsGate.com Web Services - Position sharing over the Internet.
The GpsGate Server AJAX API enables integration of live position data and tracks from GpsGate.com or any other GpsGate Server installation to your web page.
Just by quick and easy "cut and paste programming" from our examples you can display the live positions for a group of users on your web page. With simple javascript programming you can build more advanced integrations with our AJAX API. Have a look at our examples for inspiration!
More info here