/js/geo_position_js_simulator.js

http://geo-location-javascript.googlecode.com/ · JavaScript · 42 lines · 29 code · 2 blank · 11 comment · 2 complexity · e2508e5d24ab7645ad10469c0ff797ce MD5 · raw file

  1. /*!
  2. * geo-location-javascript v0.4.1 Simulator
  3. * http://code.google.com/p/geo-location-javascript/
  4. *
  5. * Copyright (c) 2009 Stan Wiechers
  6. * Licensed under the MIT licenses.
  7. *
  8. * Revision: $Rev: 62 $:
  9. * Author: $Author: whoisstan $:
  10. * Date: $Date: 2009-12-17 15:46:49 -0500 (Thu, 17 Dec 2009) $:
  11. */
  12. var geo_position_js_simulator=function(){
  13. var pub = {};
  14. var current_pos=null;
  15. pub.init = function(array)
  16. {
  17. var next=0;
  18. for (i in array)
  19. {
  20. if(i==0)
  21. {
  22. current_pos=array[i];
  23. }
  24. else
  25. {
  26. setTimeout((function(pos) {
  27. return function() {
  28. current_pos=pos;
  29. }
  30. })(array[i]),next);
  31. }
  32. next+=array[i].duration;
  33. }
  34. }
  35. pub.getCurrentPosition = function(locationCallback,errorCallback)
  36. {
  37. locationCallback(current_pos);
  38. }
  39. return pub;
  40. }();