SymbolPointCubeEvent.js 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import GraphicsLayer from "@arcgis/core/layers/GraphicsLayer.js";
  2. import Graphic from "@arcgis/core/Graphic.js";
  3. import Point from "@arcgis/core/geometry/Point.js";
  4. //测试数据
  5. import Path from '../../config/pathJson.json'
  6. class SymbolPointCubeEvent{
  7. constructor(options) {
  8. this.view = options.view;
  9. this.points = options.points;
  10. this.size = options.size;
  11. this.graphicsLayer = null;
  12. this.add();
  13. }
  14. add(){
  15. this.graphicsLayer = new GraphicsLayer({
  16. id: "symbolPointCubeEvent",
  17. title: "绘制立方体"
  18. });
  19. //this.points = Path.ypPath;
  20. this.points.forEach((point)=>{
  21. let geometry = new Point({
  22. type:"point",
  23. spatialReference:this.view.spatialReference,
  24. x:point.x,
  25. y:point.y,
  26. z:point.z
  27. });
  28. let symbol = {
  29. type: "point-3d",
  30. symbolLayers: [{
  31. type: "object",
  32. material: {
  33. color: [0, 255, 0,0.3]
  34. },
  35. resource: { primitive: "cube" },
  36. width: this.size.x, // the width in m
  37. height: this.size.y, // the height in m
  38. depth:this.size.z
  39. }]
  40. };
  41. let graphic = new Graphic({
  42. geometry: geometry,
  43. symbol: symbol
  44. });
  45. this.graphicsLayer.add(graphic);
  46. })
  47. }
  48. clear(){
  49. this.graphicsLayer.removeAll();
  50. }
  51. }
  52. export default SymbolPointCubeEvent;