http://stackoverflow.com/questions/1058880/can-iphone-send-gps-coordinates-to-a-website-painlessly
up vote
7
down vote
accepted
Please login or register to vote for this post.
(click on this box to dismiss)
Here's a snippet on how to read location from the iPhone. Looks like it requires 3.0:
navigator.geolocation.getCurrentPosition(foundLocation, noLocation);
function foundLocation(position)
{
var lat = position.coords.latitude;
var long = position.coords.longitude;
alert('Found location: ' + lat + ', ' + long);
}
function noLocation()
{
alert('Could not find location');
}
See: http://mapscripting.com/how-to-use-geolocation-in-mobile-safari
By the way, if you want to use web code on the iPhone, there are a couple middle-ground solutions you could try that don't force you to create a native app but allow you to wrap your site in an app and get access to GPS and other native features.
PhoneGap: http://phonegap.com/
Appcelerator: http://www.appcelerator.com/products/titanium-mobile/
link
flag
ไม่มีความคิดเห็น:
แสดงความคิดเห็น