Making changes to the phonegap javascript?

7 views
Skip to first unread message

Hugo

unread,
Sep 8, 2009, 1:56:16 AM9/8/09
to phonegap
How can one make changes to the phonegap Javascript (iphone app)? I
tried making simple changes to /javascript/iphone/geolocation.js as a
test, and I can see the changes make their way into lib/iphone/
phonegap.js and lib/iphone/phonegap-min.js when building the app, but
at run-time I am not seeing any of the expected changes being picked
up? What am I missing?

The simple change in /javascript/iphone/geolocation.js consisted in
inserting a do-nothing setLocation() function
<code>Geolocation.prototype.setLocation = function(position) {}</code>
and I would have expected watchPosition() to not return any new
coordinates as a consequence.

For good measure I also replaced the setLocation function with a do
nothing function in javascript/geolocation.js...not to avail, my
callBack function still gets called with updated coordinates.

Thanks in advance for the help!




A little bit of background: I am trying to test out a theory that
would explain why my phonegap iphone app gets a crappy accuracy in
situations where the maps application gets a great accuracy
(especially obvious outside of urban areas where maps gives me an
accuracy in the 10-100m range but the accuracy for my app is
consistently in the multiple 1000m's range). Needless to say I will
share my learnings with the community if I manage to get anywhere with
my experimentations

Shazron Abdullah

unread,
Sep 8, 2009, 8:09:47 PM9/8/09
to Hugo, phonegap
Tried a Clean?
If not verify that the phonegap.js in your app bundle (in the builds/$
{TARGET}) directory (Option-Click -> Show Package Contents on
the .app) is recent as of your change.

Xcode probably didn't pick up that anything changed because the js
files are not tracked by it.

Hugo

unread,
Sep 9, 2009, 4:56:26 AM9/9/09
to phonegap
Thanks for the advices: Cleaned, deleted folders from the build
directory, deleted any phonegap app from the phone/simulator, made
neutral changes to index.html to make sure xCode would have something
to pick up, and verified that the version of phonegap.js in the app
bundle reflected my changes to the phonegap javascript.

Behavior at run-time still unaffected - this is driving me nuts :
( Running out of ideas for the night. Hopefully I'll wake up smarter
tomorrow

Hugo

On Sep 8, 5:09 pm, Shazron Abdullah <shazron.abdul...@nitobi.com>
wrote:

Hugo

unread,
Sep 10, 2009, 4:32:34 PM9/10/09
to phonegap
As I found out, the navigator.geolocation object references the Safari
Geolocation API, not the Geolocation() phonegap function....so my
changes to the Phonegap Geolocation APIs weren't being picked up
because it is the Safari geolocation APIs being invoked at run-time.

A negative side effect is that the Safari API isn't nearly as
responsive or accurate as the iPhone native APIs (I think the Safari
geolocation stuff uses tower triangulation + Wifi location databases
but doesn't make use of GPS signals). I don't think this was intended
because the purpose of Phonegap is to leverage native APIs?
Reply all
Reply to author
Forward
0 new messages