vizLayer_animatorPoint.html 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!--********************************************************************
  2. * Copyright© 2000 - 2021 SuperMap Software Co.Ltd. All rights reserved.
  3. *********************************************************************-->
  4. <!DOCTYPE html>
  5. <html>
  6. <head>
  7. <meta charset="utf-8">
  8. <title data-i18n="resources.title_animatorPoint"></title>
  9. <style type="text/css">
  10. body {
  11. margin: 0;
  12. overflow: hidden;
  13. background: #fff;
  14. width: 100%;
  15. height: 100%
  16. }
  17. #map {
  18. position: absolute;
  19. width: 100%;
  20. height: 100%;
  21. }
  22. #toolbar {
  23. position: absolute;
  24. top: 50px;
  25. right: 10px;
  26. text-align: center;
  27. z-index: 100;
  28. border-radius: 4px;
  29. }
  30. </style>
  31. </head>
  32. <body>
  33. <div id="toolbar" class="panel panel-primary">
  34. <div class='panel-heading'>
  35. <h5 class='panel-title text-center' data-i18n="resources.title_animatorPoint"></h5></div>
  36. <div class='panel-body content'>
  37. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_start" onclick="startAnimator()"/>&nbsp;
  38. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_pause" onclick="pauseAnimator()"/>&nbsp;
  39. <input type="button" class="btn btn-default" data-i18n="[value]resources.btn_removeOldPoint" data-i18n="[title]resources.text_removeDrawedPoint" onclick="removeDrawedFeature()"/>
  40. </div>
  41. </div>
  42. <div id="map"></div>
  43. <script type="text/javascript" include="bootstrap,widgets.alert" src="../js/include-web.js"></script>
  44. <script type="text/javascript" exclude="iclient-classic" src="../../dist/classic/include-classic.js"></script>
  45. <script>
  46. var map, layer, animatorVector;
  47. var style =
  48. {
  49. fillColor: "#339933",
  50. fillOpacity: 1,
  51. strokeOpacity: 0,
  52. pointRadius: 5
  53. };
  54. init();
  55. function init() {
  56. if (!document.createElement('canvas').getContext) {
  57. widgets.alert.showAlert(resources.msg_supportCanvas, false);
  58. return;
  59. }
  60. map = new SuperMap.Map("map", {
  61. controls: [
  62. new SuperMap.Control.ScaleLine(),
  63. new SuperMap.Control.Zoom(),
  64. new SuperMap.Control.MousePosition(),
  65. new SuperMap.Control.Navigation({
  66. dragPanOptions: {
  67. enableKinetic: true
  68. }
  69. })]
  70. });
  71. map.addControl(new SuperMap.Control.LayerSwitcher(), new SuperMap.Pixel(42, 80));
  72. layer = new SuperMap.Layer.CloudLayer();
  73. map.addLayers([layer]);
  74. map.setCenter(new SuperMap.LonLat(0, 0), 1);
  75. animatorVector = new SuperMap.Layer.AnimatorVector("Vector Layer", {needRecordDrawedFeature: true}, {
  76. speed: 0.05,
  77. startTime: 0,
  78. endTime: 100
  79. });
  80. map.addLayers([animatorVector]);
  81. addPoint();
  82. }
  83. function addPoint() {
  84. var pointFeatures = [];
  85. var features = [];
  86. var ti = 100;
  87. var num = 100;
  88. for (var i = 0; i < ti; i++) {
  89. for (var j = 0; j < num; j++) {
  90. if (features.length >= num) {
  91. var x = features[features.length - num].geometry.x;
  92. var y = features[features.length - num].geometry.y;
  93. }
  94. else {
  95. var x = Math.random() * 20037508 * 2 - 20037508;
  96. var y = Math.random() * 20037508 * 2 - 20037508;
  97. }
  98. var xd = Math.random() * 1375080 * 2 - 1375080;
  99. var yd = Math.random() * 1375080 * 2 - 1375080;
  100. var point = new SuperMap.Geometry.Point(x + xd, y + yd);
  101. var pointFeature = new SuperMap.Feature.Vector(point, {
  102. FEATUREID: j,
  103. TIME: 0 + i * 1
  104. }, style);
  105. features.push(pointFeature);
  106. }
  107. }
  108. animatorVector.addFeatures(features);
  109. }
  110. function startAnimator() {
  111. animatorVector.animator.start();
  112. }
  113. function pauseAnimator() {
  114. animatorVector.animator.pause();
  115. }
  116. function removeDrawedFeature() {
  117. var features = animatorVector.getDrawedFeatures();
  118. animatorVector.removeFeatures(features);
  119. }
  120. </script>
  121. </body>
  122. </html>