ShotScreenControl.js 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright (c) 2000-2011 by SuperMap Software Co., Ltd.*/
  2. /**
  3. * Class: SuperMap.ShotScreenControl
  4. * 支持安卓截图功能。
  5. */
  6. SuperMap.ShotScreenControl = SuperMap.Class({
  7. /**
  8. * Constructor: SuperMap.ShotScreenControl
  9. * 构造函数。
  10. *
  11. * 例如:
  12. * (start code)
  13. * var control = new SuperMap.ShotScreenControl();
  14. control.shot();
  15. * (end)
  16. */
  17. initialize: function() {
  18. },
  19. /**
  20. * Method: shot
  21. * 截图。
  22. */
  23. shot: function(){
  24. try{
  25. var tm = this.getDate();
  26. var n = "print_image_"+tm+".png";
  27. //var m = window;//document.getElementsByTagName("body")[0];
  28. //var w = m.innerWidth//m.clientWidth;
  29. //var h = m.innerHeight;
  30. cordova.exec(function(){alert("截图保存到:sdcard/SuperMap/"+n);}, function(e){alert("截图失败了");}, "ShotScreen","action", [n]);
  31. }
  32. catch(e){
  33. alert("截图失败");
  34. }
  35. },
  36. /**
  37. * Method: getDate
  38. * 获取时间。
  39. */
  40. getDate:function(){
  41. var d = new Date();
  42. var h = d.getHours();
  43. var m = d.getMinutes();
  44. var s = d.getSeconds();
  45. var mo = d.getMonth()+1;
  46. var da = d.getDate();
  47. return mo+"_"+da+"_"+h+"_"+m+"_"+s;
  48. },
  49. /**
  50. * APIMethod: destroy
  51. * 释放资源,将引用资源的属性置空。
  52. */
  53. destroy: function() {
  54. },
  55. CLASS_NAME: "SuperMap.ShotScreenControl"
  56. });