0

I'm using Cordova 2.9.0 and Xcode 5.0

I'm trying to do this tutorial: http://docs.phonegap.com/en/2.4.0/cordova_geolocation_geolocation.md.html

I copied the code from the geolocation.getCurrentPosition and there the "Full Example" (with html and javascript-code)

I checked my config.xml and it has

<feature name="Geolocation">
  <param name="ios-package" value="CDVLocation"/>
</feature>

All I'm getting in the iPhone-Simulator is: "Finding geolocation..." But I waited for like 5mins and nothing happened - not getting any geolocation-data.

I hope someone could help me

1 Answers1

0

You can try a few things, or post more details if these fail to resolve it:

  • Your link points to the Cordova docs for version 2.4 and you are using 2.9, so although the spec for geolocation has not changed much, better to use the docs for that version.

  • Check that you are including the cordova.js file. In the example in the docs the js file is named "cordova-x.x.x.js", you of course need to substitute that for the correct file name for your project/version.

  • On the iPhone emulator (not the best way to check geolocation really) check that you have a mock location setup: Go to Debug > Location and select a predefined location or a custom one.

  • Add console.log() calls or alert() to check whether the listener is being executed at all and to check for the presence of the plugin, like:

    function onDeviceReady() {
    alert("on device ready listener executed");
    alert(navigator.geolocation);
    navigator.geolocation.getCurrentPosition(onSuccess, onError);
    }

AJJ
  • 7,365
  • 7
  • 31
  • 34
  • thanks for the fast answer.
    two questions:
    how do i install the console- and alert-plugin
    - i do have a cordova-2.5.0.js file in www-folder, not a cordova-2.9.0.js - i checked back in the folder, where i downloaded phonegap-2.9.0. there is only a cordova.js in the folder phonegap-2.9.0>lib>ios>CordovaLib. should i replace the cordova-2.5.0.js with this cordova.js?
    – Daniel von Matterhorn Nov 02 '13 at 16:12
  • sorry for the weird formatting - i don't quite know how to do line-breaks in a comment (i thought with
    or with 2 spaces)
    – Daniel von Matterhorn Nov 02 '13 at 16:20
  • About `console` in Cordova 2.9: http://stackoverflow.com/questions/17735084/cordova-2-9-3-0-no-console-log. I'm pretty sure alert() works without the notification plugin, but if not, you'll need that one. Yes, you are indeed supposed to use a cordova.js file that matches your version of Cordova, it's different for every version and platform. – AJJ Nov 02 '13 at 18:25