first, i'm trying dashcode tool to training myself with simple webapps
i got a simple question (i hope so): i need to get the device's speed
via gps
i know today it's possible to get position data into webapps:
http://developer.apple.com/mac/library/documentation/AppleApplications/Reference/WebKitDOMRef/Coordinates_idl/Classes/Coordinates/index.html
there seems to be all i have to know about it, but i can't figure out
how i will get the data in the webapp, or: i don't undertand what i
have to write in my javascript to get iphone's speed using these
classes
simply i need the js code to get speed...
anybody out there may help me?
thanks!
matteo (italia)
{
// PROMPT THE LONGITUDE
alert(position.coords.latitude, position.coords.longitude));
alert(position.coords.latitude, position.coords.latitude);
}
function errorCallback()
{ alert('error'); }
function myPosition()
{
// GET GEOLOCALISATION INFOS FROM THE BROWSER
navigator.geolocation.getCurrentPosition(getPosition, errorCallback, {maximumAge:600000});
}--
You received this message because you are subscribed to the Google Groups "iPhoneWebDev" group.
To post to this group, send email to iphone...@googlegroups.com.
To unsubscribe from this group, send email to iphonewebdev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/iphonewebdev?hl=en.
http://segdeha.com/w/geolocation.html
To track speed, you would need to track your location over time.
Easiest might be to set up a setInterval call to get the location
every few seconds and save it to an array. Something like the
following (untested):
var readings = [];
setTimeout(function () {
navigator.geolocation.getCurrentPosition(function(position) {
readings.push(position.coords);
});
}, 10000); // repeat every 10 seconds
Once you have your readings, here is a script that may be helpful for
finding distances based on Latitude/Longitude:
http://segdeha.com/e/haversine/
Good luck!
• timestamp: 1261955498739
• coords: [xpconnect wrapped (nsISupports, nsIDOMGeoPositionCoords, nsIClassInfo)]
• contractID:
• classDescription: wifi geo location position object
• classID: null
• implementationLanguage: 2
• flags: 8
• SINGLETON: 1
• THREADSAFE: 2
• MAIN_THREAD_ONLY: 4
• DOM_OBJECT: 8
• PLUGIN_OBJECT: 16
• EAGER_CLASSINFO: 32
• CONTENT_NODE: 64
• RESERVED: 2147483648
Remi
> wrote: >> many thanks! i will try asap (now i'm in trouble with a 'if' loop) > >-- > >You received this message because you are subscribed to the Google Groups "iPhoneWebDev" group. >To post to this group, send email to iphone...@googlegroups.com. >To unsubscribe from this group, send email to iphonewebdev...@googlegroups.com. >For more options, visit this group at http://groups.google.com/group/iphonewebdev?hl=en. > >
I just implemented this myself and found a bit of an issue.
Calls to getCurrentPosition() are highly inaccurate, if you have not
recently used GoogleMaps or are on a SkyHook Network Node. I found
this out, while taking the dog for a walk in the park. Droid was Spot
on, but the iPhone stayed at the house or the cell tower.
This morning I discovered that watchPosition() worked like a charm.
You may want to go with that.
-Dylan