Is it possible to use a GPS device with a computer to provide location to browsers?
I have two GPS devices, one from NMEA and one from Garmin. I would like to know if it’s possible to use either of them to provide more accurate location for browsers (Chrome, Firefox).
The web application I have works great on tablets with integrated GPS, but not with laptops.
Solution 1:
In order to get this working on a laptop, you'll need to have support "throughout the stack" as follows:
- Driver support - The laptop must have hardware drivers that can recognize the GPS device and interface with it, whether it's over USB or some other protocol. The drivers are usually implemented in the kernel, but if you know for a fact that you have correct drivers, the implementation is not important to you.
- Userspace APIs that use the drivers - No matter what the driver interface is or how it works, the userspace stack must be aware of the presence of the hardware GPS device, and must know how to access the hardware through a programming interface. If you have drivers ofr a GPS device, then you probably also have a userspace programming interface for it... but do you have the next part?
- Applications that use the userspace APIs - Your client application (presumably a web browser) must be aware of the userspace driver API and be able to use it gainfully to support location services.
- Application must support a location protocol compatible with the web application that is querying it -- The W3C standard for endpoint geolocation is the W3C Geolocation API so that's a good place to start. The browser must basically understand that when the web server asks for the location, the browser "understands" the request well enough to know that it needs to get geolocation data from the user.
- Application must integrate the driver into the location protocol as a supported backend.
So you end up with a technology stack something like this:
Kernel drivers <--> Userspace drivers/libraries <--> Web browser geolocation backend specific to your device's userland libraries or framework <--> Web browser protocol layer that understands an HTTP based geolocation request API, such as the W3C Geolocation API.
Right now I think the pieces that are most likely to already be available are:
- The kernel drivers and userspace libraries for the device should be provided by the manufacturer.
- the W3C Geolocation API is supported for a long time in Chrome and Firefox.
The piece that are likely to be missing is the "Web browser geolocation backend".
That is, I doubt that Firefox/Chrome actually has hardware integration support for GPS devices. There is only one implementation I'm aware of right now: Firefox has support for GPSd devices. So if your device integrates with the GPSd middleware and your operating system is one of the supported ones, it's possible. Otherwise, likely not (although it could vary if the manufacturer decides to support the entire stack, including a browser plugin).