User avatar
johan
GpsGate
Posts: 14089
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

Get GPS position from a browser using javascript

Tue Sep 25, 2007 2:54 pm

GPS in Browser - Get GPS position from a browser using javascript<br>

<br>
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.<br>
<br>
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.<br>
<br>
Make sure you have GpsGate Client Express installed, and have "GPS in Browser" added as Output. You can download GpsGate <a href="http://gpsgate.com/download" target="_blank">here</a>. GpsGate Client Express is free to use without time limit.<br>
<br>
For a simple demonstration click <a href="http://franson.com/gpsgate/gps.html" target="_blank">here</a><br>
For a sample that adds GPS position to a form click <a href="http://franson.com/gpsgate/acme_sample.html" target="_blank">here</a><br>
Connect a GPS to Google maps <a href="http://gpsgate.com/demo/gpsinbrows2.html" target="_blank">here</a><br>
<br>
Requirements<br>
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.<br>
<br>

Answers to some common questions.<br>
<br>
1. Is it safe? Which web site can access my GPS position?<br>
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.
<br>
<br>
2. Can I connect my GPS to a map on any site now?<br>
No, a web page must be specially designed to take advantage of this feature. See the developer section below for more information.<br>
<br>
3. Can I turn this feature off?<br>
Yes, simply remove "GPS in browser" from your Outputs in GpsGate. Or exit GpsGate.<br>
<br>
4. Can the GPS be turned on only when it is accessed by a page?<br>
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.
<br>
<br>
For Developers<br>
<br>
"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 <a href="/gpsgate/gps.html">gps.html</a> for a sample.<br>
<br>

Simple sample on how to get GPS position into your web page.<br>
<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><br>
<br>

<div id="time"></div><br>
<br>

<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>

<br>
Specification of object sent to getGpsInfo() callback<br>
You can also call getVersion() which will return the version object only.<br>
<br>

<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"<br>
<img src="images/gpsgate_gpsinbrowser_m.gif" width=140 height=40><br>
<br>

More GPS Web Service from Franson...<br>
<br>
GpsGate.com Web Services - Position sharing over the Internet.<br>
<br>
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.<br>
<br>
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!
<a href="http://gpsgate.com/index.php?id=68" target="_blank">More info here</a>

richardhula
Posts: 96
Joined: Sun Jul 17, 2005 6:33 pm

RE: Get GPS position from a browser using javascript

Wed Sep 26, 2007 1:29 am

Thanks for latest version Johan.

Note that web demo works fine when running GpsGate direct but fails when run as service.

Regards - Richard

steversmith1
Posts: 3
Joined: Mon Oct 01, 2007 10:01 pm
Location: USA
Contact: Website

RE: Get GPS position from a browser using javascript

Mon Oct 01, 2007 10:08 pm

Hello. I am new to the GPS Gateway. Sounds like something we can use. My question is:

Does it work with any GPS Receiver or do you support specific GPS manufactures?

I look forward to testing this out and just want to make sure I get the correct GPS device.

Steve Smith

User avatar
johan
GpsGate
Posts: 14089
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Get GPS position from a browser using javascript

Mon Oct 01, 2007 10:11 pm

GpsGate supports almost all GPS receivers. We cannot guarantee that a specific combination of GPS + computer + software works. But in most cases there are no problems. Just run the wizard and you are up and running.

Make sure you buy a GPS that supports NMEA.

Regards,
Johan

Franson Support

steversmith1
Posts: 3
Joined: Mon Oct 01, 2007 10:01 pm
Location: USA
Contact: Website

RE: Get GPS position from a browser using javascript

Mon Oct 01, 2007 10:39 pm

Thanks for the fast reply. One more question: If I simply get the GpsGate off your web site, is that the correct version? Are there any other considerations?

Steve Smith

User avatar
johan
GpsGate
Posts: 14089
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Get GPS position from a browser using javascript

Mon Oct 01, 2007 10:41 pm

Yes.

Please try. GpsGate is free to try, and the best way to learn and understand is by testing yourself :-)

Regards,
Johan

Franson Support

steversmith1
Posts: 3
Joined: Mon Oct 01, 2007 10:01 pm
Location: USA
Contact: Website

RE: Get GPS position from a browser using javascript

Thu Oct 04, 2007 4:04 am

It worked!!

Pretty slick stuff. Would this work in a Windows CE environment?

Steve Smith

User avatar
johan
GpsGate
Posts: 14089
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Get GPS position from a browser using javascript

Thu Oct 04, 2007 12:06 pm

It works for Opera Mobile:
http://www.opera.com/products/mobile/pr ... winmobile/

It might work in Pocket Internet Explorer in WM6.0, but for sure not in earlier versions.

The fallback solution for Pocket Internet Explorer is to use our GpsTools ActiveX solution:
http://franson.com/gpstools/guide.asp?s ... atform=net

See the "Access GPS from Internet Explorer HTML page" section. Download GpsTools SDK and take a look at the html sample page included.

Hopefully Microsoft will include full "Ajax" Javascript support in Pocket Internet explorer soon and then it will work with the "cross-scripting" solution presented above as well. The benefit with the solution above is that it is browser independent given that the browser fairly new.

Regards,
Johan

Franson Support

tiendung
Posts: 1
Joined: Mon Feb 25, 2008 8:01 am
Location: Singapore

RE: Get GPS position from a browser using javascript

Mon Feb 25, 2008 8:03 am

Hi,

Does GpsGate work with Minomo 0.2 on Windows Mobile 5.0? I tried but it did not work.

User avatar
johan
GpsGate
Posts: 14089
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Get GPS position from a browser using javascript

Mon Feb 25, 2008 11:05 am

The browser must support AJAX

Regards,
Johan

Franson Support

spand
Posts: 8
Joined: Fri May 09, 2008 12:43 am

RE: Get GPS position from a browser using javascript

Fri May 09, 2008 12:44 am

Hi

What does it mean [10049] Could not blind socket while im trying to use tcp/ip server option and I put my server IP address?

User avatar
johan
GpsGate
Posts: 14089
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Get GPS position from a browser using javascript

Fri May 09, 2008 11:10 am

This means that some other application on your computer is using the port, in this case port 12175 on IP address 127.0.0.1

Regards,
Johan

Franson Support

pino.giuseppe
Posts: 2
Joined: Fri May 16, 2008 4:07 pm

RE: Get GPS position from a browser using javascript

Fri May 16, 2008 4:11 pm

Hi,

Few weeks ago(April-2008) I bought at "Share.it" your software Franson GPSGATE for Windows_XP_SP2 Ver:2.61 to be used with Microsoft Internet Explorer7.0 (or Firefox).

No problem using it with "Google-Earth" ,everything is working fine.

The problem is with "GPS in Browser" function when viewing Google maps of my area : No "I am here" indication when I watch my local area with Google Maps.

Furthermore in the Franson_GPS_Gate OUTPUT, I selected :"VIEW IN BROWSER " option ,but nothing to to.

I supposed I should view an indicator like in "Google_Earth" :" I AM HERE " or am I wrong ??

All the DEMO LINKS in this FORUM work

Is there a FIX ??

As I said ,using the software with "GOOGLE_EARTH" ,it works fine. Am I missing something ??

Thanks ,best regards,waiting for your reply

Mendola Giuseppe

User avatar
johan
GpsGate
Posts: 14089
Joined: Wed Aug 04, 2004 10:40 pm
Location: Sweden
Contact: Website

RE: Get GPS position from a browser using javascript

Fri May 16, 2008 8:35 pm

In general web pages needs to be adjusted to work with "GPS in Browser". How this is made is described above in this guide.

To "hook" into an existing web page you try the sample "Show your local GPS position on all the main map sites" at the bottom of this page:
http://gpsgate.com/index.php?id=66


Regards,
Johan

Franson Support

rjwinte@yahoo.com
Posts: 6
Joined: Thu May 29, 2008 5:33 am
Location: USA

RE: Get GPS position from a browser using javascript

Thu May 29, 2008 5:55 am

I have the same problem as Mendola, no indicator in google maps. I got the Gpsgate toolbar to appear in INTERNET EXPLORER by downloading an old version PLUG IN PACK, but the Jump To button does nothing. I have google maps in my OUT list in Settings and it shows 1 Client connected. I have a new purchase/install of GPSGATE CLIENT 2.6. Google Earth works, but not Google Map. I tried it without the PLUG IN PACK and did not get the GPSGATE toolbar in EXPLORER.

Bob W.

Return to “GpsGate for Developers”