iPhone GeoLocation checkins

29 views
Skip to first unread message

Jesse MacFadyen

unread,
Jan 28, 2010, 4:29:48 AM1/28/10
to phonegap
The edge now contains patches for the following issues:

- location callbacks not called after first call
- excessive text in Allow/Disallow prompt
- watch not working ( similar to location callbacks not called after first call )
- error callback not being called

Files modified:
Location.m
geolocation.js

If you still have issues with location functionality please post them to:
http://phonegap.lighthouseapp.com/dashboard

Note: If you have previously allowed location services for your app, you will not see the Allow/Disallow prompt unless you remove + reinstall the app.
--
Jesse MacFadyen

blogs.nitobi.com/jesse
jesse.m...@nitobi.com

Canvin

unread,
Jan 28, 2010, 4:53:40 AM1/28/10
to phonegap
i'll try it.

Thanks for this fix.

> jesse.macfad...@nitobi.com

Canvin

unread,
Jan 28, 2010, 7:08:30 AM1/28/10
to phonegap
Works like a charm now especially the "watchPosition" function.

Canvin.

Todd Blanchard

unread,
Jan 28, 2010, 12:57:32 PM1/28/10
to Jesse MacFadyen, phonegap
This works pretty well, however, once getCurrentLocation is called the setLocation callback will get called until doomsday.  I think this is not what we want. (watch should do this, not get).

I worked around it in my client code by calling stop in both success and fail callbacks.  So I have this:

function getLocation(elementId) 
    {
        document.getElementById(elementId).value="Getting GPS...";
        if(navigator.geolocation)
        {
            debug.log("getLocation");
            navigator.notification.activityStart();
            var suc = function(p){
                debug.log(p.coords.latitude + " " + p.coords.longitude);
                navigator.notification.activityStop();
                document.getElementById(elementId).value= ""+p.coords.latitude + " " + p.coords.longitude;
                navigator.geolocation.stop();
            };
            var fail = function(error){
                navigator.notification.activityStop();
                document.getElementById(elementId).value="Failed to get GPS location";
                navigator.geolocation.stop();
            };
            navigator.geolocation.getCurrentPosition(suc,fail);
        }
        else
        {
            document.getElementById(elementId).value="No GPS service available.";
        }
    }

and it now works very nicely - but raises the question of whether the stop() should be called in the core code just prior to calling the callbacks.

-Todd Blanchard

--
You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com

Jesse MacFadyen

unread,
Jan 28, 2010, 5:30:49 PM1/28/10
to Todd Blanchard, phonegap
Yes, behind the scenes the LocationManager in Obj-C is running in my checkin.
Overall I do not like the interface as polling on timeouts does make sense when the native LocationManager will already do the updating.

I wanted to implement more of an eventBroadcaster pattern, but we are stuck with the standards + I did not want to break anyone's code.

I expect that most people would want to watch the location until a certain accuracy was achieved, then stop watching. 

Or perhaps be notified when location changes within a significant amount ( ie. the user has moved more than 10 meters or something similar. )

A lot of the above can be achieved by writing a wrapper plug-in method ( all in JS ) that provides a richer interface.

I will consider implementing your doomsday workaround.

Please log an issue in lighthouse app for this.
http://phonegap.lighthouseapp.com/dashboard

Thanks for keeping me honest Todd!

Cheers,
  Jesse

Todd Blanchard

unread,
Jan 28, 2010, 6:09:21 PM1/28/10
to Jesse MacFadyen, phonegap
I filed an issue and added an item to the wiki with my workaround (there was no getLocation example there yet anyhow).

Any plans to add reverse geocoding?  I'd like to get the nearest street address too.

Thomas

unread,
Jan 29, 2010, 1:02:12 PM1/29/10
to phonegap
Great news Jesse,

We'll try to port our app to 0.9 - The allow/disallow msg in 0.8.x was
the only issue we had - it was terrible and confusing for the user
although luckily it didn't block the app from hitting the AppStore :)

thanks for the great work, keep it up!

Reply all
Reply to author
Forward
0 new messages