AddGraphicsEvent.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import Graphic from "@arcgis/core/Graphic.js";
  2. import dangerIcon from "../../assets/预警.png";
  3. import Point from "@arcgis/core/geometry/Point.js";
  4. class AddGraphicsEvent {
  5. constructor(options) {
  6. this.id = options.id;
  7. this.view = options.view;
  8. this.data = options.data;
  9. this.add();
  10. }
  11. add(){
  12. let point = new Point({
  13. type: "point", // autocasts as new Point()
  14. x: this.data.geometry.x,
  15. y: this.data.geometry.y,
  16. z: this.data.geometry.z,
  17. spatialReference: this.view.spatialReference
  18. })
  19. let graphic = new Graphic({
  20. id: this.id,
  21. geometry: point,
  22. attributes: this.data.attributes,
  23. symbol:{
  24. type: "point-3d",
  25. symbolLayers: [
  26. {
  27. type: "icon",
  28. resource: {
  29. href: dangerIcon
  30. },
  31. size: 50,
  32. outline: {
  33. color: "white",
  34. size: 2
  35. }
  36. }
  37. ]
  38. },
  39. });
  40. this.view.graphics.add(graphic)
  41. }
  42. }
  43. export default AddGraphicsEvent;