integrate-map.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <title>Organization Chart Plugin</title>
  6. <link rel="icon" href="img/logo.png">
  7. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.18.2/ol.css">
  8. <link rel="stylesheet" href="css/font-awesome.min.css">
  9. <link rel="stylesheet" href="css/jquery.orgchart.css">
  10. <link rel="stylesheet" href="css/style.css">
  11. <style type="text/css">
  12. #chart-container {
  13. position: absolute;
  14. top: 10px;
  15. left:40px;
  16. height: auto;
  17. max-height: 330px;
  18. width: calc(100% - 80px);
  19. z-index: 1;
  20. border-color: rgba(217, 83, 79, 0.9);
  21. }
  22. .orgchart {
  23. background: rgba(255,255,255,0.75);
  24. }
  25. </style>
  26. </head>
  27. <body id="pageBody">
  28. <div id="chart-container"></div>
  29. <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/ol3/3.18.2/ol.js"></script>
  30. <script type="text/javascript" src="js/jquery.min.js"></script>
  31. <script type="text/javascript" src="js/jquery.orgchart.js"></script>
  32. <script type="text/javascript">
  33. $(function() {
  34. var map = new ol.Map({
  35. layers: [
  36. new ol.layer.Tile({
  37. source: new ol.source.Stamen({
  38. layer: 'watercolor'
  39. }),
  40. preload: 4
  41. }),
  42. new ol.layer.Tile({
  43. source: new ol.source.Stamen({
  44. layer: 'terrain-labels'
  45. }),
  46. preload: 1
  47. })
  48. ],
  49. target: 'pageBody',
  50. view: new ol.View({
  51. center: ol.proj.transform([-87.6297980, 41.8781140], 'EPSG:4326', 'EPSG:3857'),
  52. zoom: 10
  53. })
  54. });
  55. $('body').prepend(map.getViewport());
  56. var datascource = {
  57. 'name': 'Lao Lao',
  58. 'title': 'President Office',
  59. 'position': [-87.6297980, 41.8781140],
  60. 'children': [
  61. { 'name': 'Bo Miao', 'title': 'Administration Dept.', 'position': [-83.0457540, 42.3314270]},
  62. { 'name': 'Su Miao', 'title': 'R & D Dept.', 'position': [-81.6943610, 41.4993200]},
  63. { 'name': 'Yu Jie', 'title': 'Product Dept.', 'position': [-71.0588800, 42.3600820]},
  64. { 'name': 'Yu Li', 'title': 'Legal Dept.', 'position': [-74.0059410, 40.7127840]},
  65. { 'name': 'Hong Miao', 'title': 'Finance Dept.', 'position': [-80.8431270, 35.2270870]},
  66. { 'name': 'Yu Wei', 'title': 'Security Dept.', 'position': [-81.6556510, 30.3321840]},
  67. { 'name': 'Chun Miao', 'title': 'HR Dept. ', 'position': [-81.3792360, 28.5383350]},
  68. { 'name': 'Yu Tie', 'title': 'Marketing Dept.', 'position': [-80.1917900, 25.7616800] }
  69. ]
  70. };
  71. $('#chart-container').orgchart({
  72. 'data' : datascource,
  73. 'nodeContent': 'title',
  74. 'createNode': function($node, data) {
  75. $node.on('click', function() {
  76. var view = map.getView();
  77. var duration = 2000;
  78. var start = +new Date();
  79. var pan = ol.animation.pan({
  80. duration: duration,
  81. source: view.getCenter(),
  82. start: start
  83. });
  84. var bounce = ol.animation.bounce({
  85. duration: duration,
  86. resolution: 4 * view.getResolution(),
  87. start: start
  88. });
  89. map.beforeRender(pan, bounce);
  90. view.setCenter(ol.proj.transform(data.position, 'EPSG:4326', 'EPSG:3857'));
  91. });
  92. }
  93. });
  94. });
  95. </script>
  96. </body>
  97. </html>