Advertisement
Guest User

Untitled

a guest
Mar 28th, 2012
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.28 KB | None | 0 0
  1. {
  2. print: function ( map )
  3. {
  4. var div = dom.byId( "printOutput" );
  5. div.innerHTML = " ";
  6. this.test( div, this.printLayers( map ) );
  7. this.test( div, this.printSvg( map ) );
  8. },
  9.  
  10. printSvg: function ( map )
  11. {
  12. var viewBoxItems = query( "svg", map ).filter( function ( item )
  13. {
  14. return item.viewBox;
  15. } );
  16. var images = [];
  17. array.forEach( viewBoxItems, function ( viewBoxItem )
  18. {
  19. array.forEach( query( "g img", viewBoxItem ), function ( img )
  20. {
  21. images.push( img );
  22. } );
  23. } );
  24.  
  25. var pos = array.map( images, function ( img )
  26. {
  27. var pos;
  28. pos = dojo.position( img );
  29. pos.src = img.href.baseVal;
  30. return pos;
  31. } );
  32.  
  33. var polylines = [];
  34. array.forEach( viewBoxItems, function ( viewBoxItem )
  35. {
  36. array.forEach( query( "g polyline", viewBoxItem ), function ( shape )
  37. {
  38. polylines.push( shape.points );
  39. } );
  40. } );
  41.  
  42. return {
  43. images: pos,
  44. polylines: polylines
  45. };
  46. },
  47.  
  48. printLayers: function ( map )
  49. {
  50. var images = query( "div img", map ).filter( function ( img )
  51. {
  52. return 256 === domStyle.get( img, "width" );
  53. } );
  54.  
  55. var pos = array.map( images, function ( img )
  56. {
  57. var pos;
  58. pos = dojo.position( img );
  59. pos.src = img.src;
  60. return pos;
  61. } );
  62.  
  63. return { images: pos };
  64. },
  65.  
  66. test: function ( div, imagery )
  67. {
  68. var images = imagery.images;
  69. if ( images )
  70. {
  71. images = array.map( images, function ( item )
  72. {
  73. var img = dojo.create( "img", {
  74. src: item.src
  75. } );
  76.  
  77. domStyle.set( img, {
  78. position: "absolute",
  79. left: item.x + "px",
  80. top: item.y + "px",
  81. width: item.w + "px",
  82. height: item.h + "px"
  83. } );
  84.  
  85. return img;
  86. } );
  87. }
  88.  
  89. array.forEach( images, function ( img )
  90. {
  91. div.appendChild( img );
  92. } );
  93.  
  94. if ( imagery.polylines )
  95. {
  96. // render vector data
  97. }
  98. }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement