So it looks like mobile phones these days are capable of providing gps data ;)
I'm building a django app with a mobile edition that I want to be location aware.
My question is, how does one access GPS data? Is there a st开发者_运维问答andard, or do you have to custom code for android/iphone/other.
Ideally, I'd imagine it being provided in the HTTP request in the same way you get information such as the IP Address and User Agent.
There's a really good blog post about this topic, covering a variety of methods @
http://hitching.net/2009/11/10/location-aware-mobile-web-apps-using-google-maps-v3-geolocation/
Question is quite old, but still users will be redirected here from google, so update:
As for now, the HTML5 geolocation is a standard
You can read Geolocation API specification on W3C and see the Where am I? app to check your desktop/mobile browser support.
HTML5 geolocation is available for Opera/Opera Mobile, Firefox (both desktop and mobile), IE for desktops (unfortunatelly, not mobile version for Windows Phone 7), Safari (both desktop and mobile), Chrome and Android Browser.
Server side API will be common for all platforms (just standard HTTP requests).
GPS access is platform depend and typically You will have to write custom code for all platforms. However you can try use http://www.appcelerator.com/ - framework for crating mobile apps using Web based techniques (there is common appi for GPS access).
Your code is going to be used on a mobile client, you know it is going to be a specific kind of phone. Yes you do need to code for a specific device as the API for iPhone is not the same as for Android. Android I don't know yet - for iPhone, you need to use Core Location - the CLLocation class is a good place to start reading in the developer docs once you have Xcode open, and the Locations sample code is a nice starting point that shows how to get a series of position fixes. Maybe you can get some kind of fix back from the server but I don't think you'll find it at all accurate - that is to say not incorrect but with a very large circle of uncertainty.
精彩评论