location_utils.js 835 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var _locationSO = null;
  2. function getDeviceLocation(_callback)
  3. {
  4. var criteria = new Object();
  5. if(_locationSO == null)
  6. {
  7. _locationSO = device.getServiceObject("Service.Location", "ILocation");
  8. }
  9. criteria.LocationInformationClass = 'BasicLocationInformation';
  10. var self = this;
  11. try
  12. {
  13. _locationSO.ILocation.GetLocation(criteria, function(transId, eventCode, result)
  14. {
  15. getDeviceLocationCallback(transId, eventCode, result, _callback);
  16. });
  17. }
  18. catch(e)
  19. {
  20. //alert(e);
  21. _callback(null, null, null, true);
  22. }
  23. }
  24. function getDeviceLocationCallback(transId, eventCode, result, _callback)
  25. {
  26. if(eventCode != 4)
  27. {
  28. _callback(result.ReturnValue, result.ErrorCode, result.ErrorMessage)
  29. }
  30. else if(eventCode == 4)
  31. {
  32. _callback(null, -1, "Generic error");
  33. }
  34. else
  35. {
  36. }
  37. }