You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sz_out.html 5.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. <div id="viewer-container" class="sz-container"></div>
  2. <script>
  3. let viewer = undefined
  4. let szData = undefined
  5. let sz_out_data = undefined
  6. let sz_zxd_data =[
  7. {
  8. label:"姑苏区",
  9. coord:"120.59665360,31.32417637"
  10. },
  11. {
  12. label:"吴中区",
  13. coord:"120.26656151,31.12600545"
  14. },
  15. {
  16. label:"吴江区",
  17. coord:"120.61407203,31.00940314"
  18. },
  19. {
  20. label:"相城区",
  21. coord:"120.61658599,31.44896501"
  22. },
  23. {
  24. label:"虎丘区",
  25. coord:"120.42240336,31.35921238"
  26. },
  27. {
  28. label:"工业园区",
  29. coord:"120.73975003,31.33381359"
  30. },
  31. {
  32. label:"昆山市",
  33. coord:"120.96280041,31.31506478"
  34. },
  35. {
  36. label:"太仓市",
  37. coord:"121.15395177,31.57029622"
  38. },
  39. {
  40. label:"常熟市",
  41. coord:"120.81050568,31.66691104"
  42. },
  43. {
  44. label:"张家港市",
  45. coord:"120.61839073,31.90941293"
  46. },
  47. ]
  48. function loadVLine (){
  49. let layer = new DC.PrimitiveLayer('vLine_layer')
  50. viewer.addLayer(layer)
  51. let positions =[
  52. {lng: 119.61305431791536, lat: 31.949257981346843},
  53. {lng: 119.66748528834533, lat: 31.569088949848066},
  54. {lng: 119.93621458239951, lat: 30.862978381864128},
  55. {lng: 120.33269379413352, lat: 30.779032494324515},
  56. {lng: 120.91846175667051, lat: 30.772412670398687},
  57. {lng: 121.37081537125513, lat: 31.031108498202467},
  58. {lng: 121.68788865110909, lat: 31.59956942613548},
  59. {lng: 121.31821229420665, lat: 32.00645809208013},
  60. ]
  61. positions.forEach(item=>{
  62. let position = DC.Position.fromObject(item)
  63. let end = position.copy()
  64. end.alt = 80000 * Math.random()
  65. let line = new DC.FlowLinePrimitive([position,end],0.5)
  66. line.setStyle({
  67. speed: 8,
  68. color: DC.Color.fromCssColorString("rgb(240,131,61)"),
  69. percent:0.2,
  70. gradient:0.01
  71. })
  72. layer.addOverlay(line)
  73. })
  74. }
  75. function loadSzData(){
  76. szData = new DC.GeoJsonLayer('sz','examples/data/sz.geojson')
  77. sz_out_data = new DC.GeoJsonLayer('sz-out','examples/data/sz_out.geojson')
  78. }
  79. function loadSzZxd(){
  80. let layer_sz_zxd = new DC.VectorLayer('layer-sz-zxd').addTo(viewer)
  81. sz_zxd_data.forEach(item=>{
  82. let position = DC.Position.fromString(item.coord)
  83. position.alt = 3000
  84. let billboard = new DC.Billboard(position,'../assets/bg/bg_name.png')
  85. billboard.size = [item.label.length * 25,32]
  86. billboard.setStyle({
  87. scale:0.8,
  88. distanceDisplayCondition:{
  89. near:0,
  90. far:2.5e5
  91. }
  92. })
  93. billboard.setLabel(item.label,{
  94. font:"10px",
  95. disableDepthTestDistance:Number.POSITIVE_INFINITY,
  96. distanceDisplayCondition:{
  97. near:0,
  98. far:2.5e5
  99. }
  100. })
  101. let circle = new DC.Circle(position,2000)
  102. circle.setStyle({
  103. height:2000,
  104. material: new DC.CircleWaveMaterialProperty({
  105. speed:5,
  106. color: DC.Color.fromCssColorString("rgb(205,100,33)")
  107. })
  108. })
  109. layer_sz_zxd.addOverlay(billboard).addOverlay(circle)
  110. })
  111. }
  112. function loadSzPolygon(){
  113. viewer.addLayer(sz_out_data)
  114. sz_out_data.eachOverlay(entity =>{
  115. DC.Util.merge(entity.polygon,{
  116. outline:false,
  117. material:DC.Color.fromCssColorString("rgb(47,50,54)"),
  118. extrudedHeight:2000
  119. })
  120. })
  121. }
  122. function loadSzOutline(){
  123. let layer_sz_outline = new DC.VectorLayer('layer-sz-outline').addTo(viewer)
  124. let now = DC.JulianDate.now()
  125. sz_out_data.eachOverlay(entity => {
  126. if(entity.polygon){
  127. let positions = DC.Transform.transformCartesianArrayToWGS84Array(
  128. entity.polygon.hierarchy.getValue(now).positions
  129. )
  130. positions.map(item=>{
  131. item.alt = 2000
  132. })
  133. let polyline = new DC.Polyline(positions)
  134. polyline.setStyle({
  135. width:2,
  136. material: new DC.PolylineTrailMaterialProperty({
  137. speed:2,
  138. color: DC.Color.fromCssColorString("rgb(149,236,217)")
  139. })
  140. })
  141. layer_sz_outline.addOverlay(polyline)
  142. }
  143. })
  144. }
  145. function loadSzLine(){
  146. let layer_sz = new DC.VectorLayer('layer-sz-line').addTo(viewer)
  147. let now = DC.JulianDate.now()
  148. szData.eachOverlay(entity => {
  149. if(entity.polygon){
  150. let positions = DC.Transform.transformCartesianArrayToWGS84Array(
  151. entity.polygon.hierarchy.getValue(now).positions
  152. )
  153. positions.map(item=>{
  154. item.alt = 2000
  155. })
  156. let polyline = new DC.Polyline(positions)
  157. polyline.setStyle({
  158. width:1,
  159. material:new DC.PolylineFlickerMaterialProperty({
  160. speed:10 * Math.random(),
  161. color: DC.Color.fromCssColorString("rgb(116,173,250)")
  162. })
  163. })
  164. layer_sz.addOverlay(polyline)
  165. }
  166. })
  167. }
  168. function initViewer() {
  169. viewer = new DC.Viewer('viewer-container',{
  170. orderIndependentTranslucency: false,
  171. contextOptions: {
  172. webgl: {
  173. alpha: true
  174. }
  175. }
  176. })
  177. viewer.setOptions({
  178. showMoon: false,
  179. showSun: false,
  180. enableFaxx:true,
  181. globe:{
  182. show:false
  183. },
  184. skyBox:{
  185. show:false
  186. }
  187. })
  188. viewer.use(new DC.Effect())
  189. loadVLine()
  190. viewer.zoomToPosition("120.6119943479279,30.237286794313203,126132.920,0,-48.84",()=>{
  191. loadSzData()
  192. loadSzOutline()
  193. loadSzPolygon()
  194. loadSzLine()
  195. loadSzZxd()
  196. })
  197. }
  198. </script>