Guest User

Untitled

a guest
Apr 21st, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. Sandcastle.addToolbarButton('Search', function() {
  2.  
  3. var dataSource2 = new Cesium.GeoJsonDataSource();
  4. var promise = dataSource2.load('Apps/SampleData/Buildings.geojson');
  5. promise.then(function(dataSource2) {
  6. viewer.dataSources.add(dataSource2);
  7. //viewer.zoomTo(dataSource2);
  8.  
  9.  
  10. //Get the array of entities
  11. var entities2 = dataSource2.entities.values;
  12. var colorHash = {};
  13. for (var i = 0; i < entities2.length; i++) {
  14. //For each entity, create a random color based on the state name.
  15. //Some states have multiple entities, so we store the color in a
  16. //hash so that we use the same color for the entire state.
  17. var entity = entities2[i];
  18. var name = entity.Height;
  19. var color = colorHash[name];
  20. if (!color) {
  21. color = Cesium.Color.BROWN;
  22. colorHash[name] = color;
  23. }
  24. //Set the polygon material to our random color.
  25. entity.polygon.material = color;
  26. //Remove the outlines.
  27. entity.polygon.outline = false;
  28. entity.polygon.extrudedHeight = entity.properties.Height;
  29.  
  30. }
  31.  
  32. for (var x=0; x<entities2.length; x++) {
  33. var name = entities2[x].properties.Name.toLowerCase();
  34. var textbox_value = document.getElementById("search").value.toLowerCase();
  35. var textbox_value_array = [];
  36. textbox_value_array.push(textbox_value);
  37. if (jQuery.inArray(name, textbox_value_array) > -1) {
  38. viewer.flyTo(entities2[x]);
  39. }
  40. }
  41.  
  42.  
  43.  
  44. });
  45.  
  46.  
  47. });
  48.  
  49.  
  50.  
  51.  
  52. Sandcastle.addToolbarButton('3D View', function() {
  53. //Seed the random number generator for repeatable results.
  54. Cesium.Math.setRandomNumberSeed(0);
  55. var dataSource1 = new Cesium.GeoJsonDataSource();
  56. var roads = dataSource1.load('Apps/SampleData/Roads_Vishak.geojson');
  57. roads.then(function(dataSource1) {
  58. viewer.dataSources.add(dataSource1);
  59. //viewer.zoomTo(dataSource1);
  60.  
  61.  
  62. //Get the array of entities
  63. var entities1 = dataSource1.entities.values;
  64.  
  65.  
  66. var colorHash = {};
  67. for (var i = 0; i < entities1.length; i++) {
  68. //For each entity, create a random color based on the state name.
  69. //Some states have multiple entities, so we store the color in a
  70. //hash so that we use the same color for the entire state.
  71. var entity = entities1[i];
  72. var name = entity.properties.highway;
  73. var color = colorHash[name];
  74. if (!color) {
  75. color = Cesium.Color.SNOW;
  76. colorHash[name] = color;
  77. }
  78. //Set the polygon material to our random color.
  79. entity.polyline.material = color;
  80. //Remove the outlines.
  81. entity.polyline.outline = false;
  82. //entity.polyline.translucent = true;
  83.  
  84.  
  85.  
  86. }
  87. }).otherwise(function(error){
  88. //Display any errrors encountered while loading.
  89. window.alert(error);
  90. });
  91. /*var dataSource2 = new Cesium.GeoJsonDataSource();
  92. var positions = []; // xy position array
  93. var promise = dataSource2.load('Apps/SampleData/Region_Point.geojson');
  94. promise.then(function(dataSource2) {
  95. viewer.dataSources.add(dataSource2);
  96. //viewer.zoomTo(dataSource2);
  97.  
  98.  
  99. //Get the array of entities
  100. var entities2 = dataSource2.entities.values;
  101.  
  102. var colorHash = {};
  103. for (var i = 0; i < entities2.length; i++) {
  104. //For each entity, create a random color based on the state name.
  105. //Some states have multiple entities, so we store the color in a
  106. //hash so that we use the same color for the entire state.
  107. var entity = entities2[i];
  108. entity.billboard = undefined;
  109. entity.point = new Cesium.PointGraphics({
  110. color: Cesium.Color.RED,
  111. pixelSize: 10
  112. });
  113.  
  114.  
  115. }
  116. }).otherwise(function(error){
  117. //Display any errrors encountered while loading.
  118. window.alert(error);
  119. });*/
  120. var dataSource3 = new Cesium.GeoJsonDataSource();
  121. var promise = dataSource3.load('Apps/SampleData/Buildings.geojson');
  122. promise.then(function(dataSource3) {
  123. viewer.dataSources.add(dataSource3);
  124. viewer.zoomTo(dataSource3);
  125.  
  126.  
  127. //Get the array of entities
  128. var entities3 = dataSource3.entities.values;
  129.  
  130. var colorHash = {};
  131. for (var i = 0; i < entities3.length; i++) {
  132.  
  133. var entity = entities3[i];
  134. var name = entity.properties.Height;
  135. var color = colorHash[name];
  136. if (!color) {
  137. color = Cesium.Color.BROWN;
  138. colorHash[name] = color;
  139. }
  140.  
  141. //Set the polygon material to our random color.
  142. entity.polygon.material = color;
  143. //Remove the outlines.
  144. entity.polygon.outline = false;
  145.  
  146.  
  147. entity.polygon.extrudedHeight = entity.properties.Height;
  148.  
  149.  
  150. }
  151. }).otherwise(function(error){
  152. //Display any errrors encountered while loading.
  153. window.alert(error);
  154. });
  155.  
  156. });
Add Comment
Please, Sign In to add comment