Advertisement
Guest User

Untitled

a guest
Sep 30th, 2016
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. var app = {
  2. // Application Constructor
  3. initialize: function() {
  4. this.bindEvents();
  5. },
  6. // Bind Event Listeners
  7. //
  8. // Bind any events that are required on startup. Common events are:
  9. // 'load', 'deviceready', 'offline', and 'online'.
  10. bindEvents: function() {
  11. document.addEventListener('deviceready', this.onDeviceReady, false);
  12. },
  13. // deviceready Event Handler
  14. //
  15. // The scope of 'this' is the event. In order to call the 'receivedEvent'
  16. // function, we must explicitly call 'app.receivedEvent(...);'
  17. onDeviceReady: function() {
  18.  
  19.  
  20.  
  21. function onSuccess(position){
  22. console.log("Latitude:" + position.coords.latitude);
  23. console.log("Longitude:" + position.coords.longitude);
  24.  
  25. };
  26.  
  27.  
  28. function onError(error) {
  29. alert('code: ' + error.code + 'n' +
  30. 'message: ' + error.message + 'n');
  31. }
  32.  
  33.  
  34. navigator.geolocation.getCurrentPosition(onSuccess, onError);
  35.  
  36. public boolean execute(String action, final JSONArray inputs, final CallbackContext callbackContext) throws JSONException {
  37. PluginResult result = null;
  38. if (action.equals("getCurrentPosition")) {
  39. this.cordova.getActivity().runOnUiThread(new Runnable() {
  40. public void run() {
  41. callbackContext.sendPluginResult(getCurrentPosition(inputs));
  42. }
  43. });
  44.  
  45. result = new PluginResult(Status.OK);
  46.  
  47. }
  48. }
  49.  
  50. app.receivedEvent('deviceready');
  51.  
  52. },
  53.  
  54. THREAD WARNING: exec() call to Geolocation.getPermission blocked the main thread for 59ms. Plugin should use CordovaInterface.getThreadPool().
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement