views:

215

answers:

3

I need to develop a web app. (PHP) 100% for mobile phones and need to get the information from the mobile phone GPS, in order to get the user's current position. My question is, what should I do?

I know PHP but I'm completely clueless about the GPS part (never worked with them before). All i'm looking is for headsup to see if I can handle the job or just reject it.

I've heard that the W3 geolocation API does a very good job but after testing it i'm not convinced about the accuracy and browser support. I don't want to use Google's gears due to the fact that it must be downloaded first.

+1  A: 

Depending on the mobile device, you may have access to GPS. However, in the broad spectrum of mobile, you probably can not reliably get it from the device's browser alone. Reading the IP would be futile considering the architecture of cellular networks.

It can be done, but you would need to build in level of degradation.

Jason McCreary
Maybe not getting it transparently thru the devices browser but what about asking for coords?
Ben
I don't think the common user is going to know that. And if you are able to provide it to them, then you have GPS data. This really comes down to your app's purpose. Ask yourself - Is having the location mandatory? Is it *bad* to ask the user for it? Are there accuracy requirements?
Jason McCreary
A: 

It depends on the device but some mobile app frameworks have done all the work for you and have Extensions to do this, check out jqTouch for the iPhone:

http://jqtouch.com/

More specifically:

http://code.google.com/p/jqtouch/wiki/Extensions

Kieran Andrews
+1  A: 

I do think the W3C Geolocation API is a good place to start: it has growing acceptance on mobile phones, is an open standard and abstracts away all the device-specific APIs.

It's true that the accuracy may not be perfect, but that's because the phone itself may not always know perfectly where it is. The API gives you a couple ways to work around this: if you need high accuracy, you can hint to the device that you want an accurate result even at the cost of power/time with the enableHighAccuracy flag and set a long timeout parameter to allow the device to use GPS to find a location. Also, all positions are returned with an accuracy value for 95% confidence -- if the error is too high (often phones will return a high error on the first request), you can request the location again, specifying that you don't want a cached location.

npdoty
@npdoty can w3c geolocation api be applied in php? or is it working in javascript alone? I have refer to the reference but clueless. thanks.
benmsia
@benmsia The W3C API is a JavaScript API, supported by a growing number of browsers. If you needed to, you could access this information by transmitting the results from JavaScript back to your server-side PHP script using AJAX -- or better yet, by having the user submit the information via a form which you've auto-filled with JavaScript.I understand that the specification itself can be hard to read: I have some sample code at http://npdoty.name/location#developer
npdoty