@honua/react 0.1.9-beta.0 → 0.1.10-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/control-plane/admin-client.d.ts +2 -0
  2. package/control-plane/admin-client.d.ts.map +1 -1
  3. package/control-plane/admin-client.js +32 -1
  4. package/control-plane/client.d.ts +1 -1
  5. package/control-plane/client.d.ts.map +1 -1
  6. package/control-plane/client.js +124 -8
  7. package/control-plane/commands/catalog.d.ts +7 -7
  8. package/control-plane/commands/catalog.d.ts.map +1 -1
  9. package/control-plane/commands/catalog.js +27 -15
  10. package/control-plane/commands/runtime.d.ts +6 -6
  11. package/control-plane/commands/runtime.d.ts.map +1 -1
  12. package/control-plane/commands/runtime.js +26 -14
  13. package/control-plane/commands/types.d.ts +4 -2
  14. package/control-plane/commands/types.d.ts.map +1 -1
  15. package/control-plane/generated/admin-api.d.ts +6 -4
  16. package/control-plane/generated/admin-api.d.ts.map +1 -1
  17. package/control-plane/generated/admin-api.js +2 -2
  18. package/control-plane/generated/admin-operations.d.ts +7 -7
  19. package/control-plane/generated/admin-operations.d.ts.map +1 -1
  20. package/control-plane/generated/admin-operations.js +9 -9
  21. package/control-plane/index.d.ts +1 -1
  22. package/control-plane/index.d.ts.map +1 -1
  23. package/control-plane/index.js +1 -1
  24. package/core/client.d.ts.map +1 -1
  25. package/core/client.js +28 -30
  26. package/core/error-envelope.d.ts +31 -0
  27. package/core/error-envelope.d.ts.map +1 -1
  28. package/core/error-envelope.js +11 -0
  29. package/core/errors.d.ts +15 -3
  30. package/core/errors.d.ts.map +1 -1
  31. package/core/errors.js +254 -2
  32. package/core/geometry-input-sr.d.ts +3 -0
  33. package/core/geometry-input-sr.d.ts.map +1 -0
  34. package/core/geometry-input-sr.js +28 -0
  35. package/core/geoservices.d.ts.map +1 -1
  36. package/core/geoservices.js +33 -6
  37. package/core/grpc-adapter.d.ts.map +1 -1
  38. package/core/grpc-adapter.js +11 -3
  39. package/core/pbf-decoder.d.ts.map +1 -1
  40. package/core/pbf-decoder.js +16 -4
  41. package/core/protocol-transport.d.ts +6 -1
  42. package/core/protocol-transport.d.ts.map +1 -1
  43. package/core/request-pipeline.d.ts +6 -3
  44. package/core/request-pipeline.d.ts.map +1 -1
  45. package/core/request-pipeline.js +28 -11
  46. package/core/spatial-filter.d.ts +4 -4
  47. package/core/spatial-filter.d.ts.map +1 -1
  48. package/core/spatial-filter.js +7 -7
  49. package/core/types.d.ts +14 -3
  50. package/core/types.d.ts.map +1 -1
  51. package/esri-compat/class-breaks-renderer.d.ts +2 -0
  52. package/esri-compat/class-breaks-renderer.d.ts.map +1 -1
  53. package/esri-compat/class-breaks-renderer.js +7 -0
  54. package/esri-compat/controls.d.ts +10 -1
  55. package/esri-compat/controls.d.ts.map +1 -1
  56. package/esri-compat/controls.js +86 -2
  57. package/esri-compat/directions.d.ts +35 -0
  58. package/esri-compat/directions.d.ts.map +1 -1
  59. package/esri-compat/directions.js +153 -2
  60. package/esri-compat/expand.d.ts +1 -0
  61. package/esri-compat/expand.d.ts.map +1 -1
  62. package/esri-compat/expand.js +61 -0
  63. package/esri-compat/feature-layer.d.ts +29 -4
  64. package/esri-compat/feature-layer.d.ts.map +1 -1
  65. package/esri-compat/feature-layer.js +335 -13
  66. package/esri-compat/geometry-engine.d.ts +4 -0
  67. package/esri-compat/geometry-engine.d.ts.map +1 -1
  68. package/esri-compat/geometry-engine.js +8 -1
  69. package/esri-compat/graphic.d.ts +7 -4
  70. package/esri-compat/graphic.d.ts.map +1 -1
  71. package/esri-compat/legend.d.ts +2 -1
  72. package/esri-compat/legend.d.ts.map +1 -1
  73. package/esri-compat/legend.js +15 -0
  74. package/esri-compat/map-view-mount.d.ts +48 -0
  75. package/esri-compat/map-view-mount.d.ts.map +1 -0
  76. package/esri-compat/map-view-mount.js +344 -0
  77. package/esri-compat/map-view.d.ts +38 -6
  78. package/esri-compat/map-view.d.ts.map +1 -1
  79. package/esri-compat/map-view.js +467 -33
  80. package/esri-compat/portal.d.ts +2 -0
  81. package/esri-compat/portal.d.ts.map +1 -1
  82. package/esri-compat/portal.js +7 -2
  83. package/esri-compat/renderer-objects.d.ts +7 -2
  84. package/esri-compat/renderer-objects.d.ts.map +1 -1
  85. package/esri-compat/renderer-objects.js +16 -5
  86. package/esri-compat/route-layer.d.ts +8 -0
  87. package/esri-compat/route-layer.d.ts.map +1 -1
  88. package/esri-compat/route-layer.js +24 -4
  89. package/esri-compat/route-task.d.ts +5 -1
  90. package/esri-compat/route-task.d.ts.map +1 -1
  91. package/esri-compat/route-task.js +119 -7
  92. package/esri-compat/scene-view.d.ts.map +1 -1
  93. package/esri-compat/scene-view.js +1 -0
  94. package/esri-compat/search.d.ts +2 -1
  95. package/esri-compat/search.d.ts.map +1 -1
  96. package/esri-compat/search.js +52 -2
  97. package/esri-compat/unique-value-renderer.d.ts +2 -0
  98. package/esri-compat/unique-value-renderer.d.ts.map +1 -1
  99. package/esri-compat/unique-value-renderer.js +7 -0
  100. package/esri-compat/web-map.d.ts +10 -0
  101. package/esri-compat/web-map.d.ts.map +1 -1
  102. package/esri-compat/web-map.js +102 -0
  103. package/map/webmap-maplibre.d.ts +2 -1
  104. package/map/webmap-maplibre.d.ts.map +1 -1
  105. package/map/webmap-maplibre.js +3 -0
  106. package/package.json +3 -3
  107. package/query-planner/geoservices.d.ts.map +1 -1
  108. package/query-planner/geoservices.js +2 -0
  109. package/query-planner/types.d.ts +2 -0
  110. package/query-planner/types.d.ts.map +1 -1
  111. package/realtime/honua-server.d.ts +4 -0
  112. package/realtime/honua-server.d.ts.map +1 -1
  113. package/realtime/honua-server.js +10 -0
  114. package/realtime/resumable.js +9 -0
  115. package/realtime/types.d.ts +8 -0
  116. package/realtime/types.d.ts.map +1 -1
  117. package/studio/capability-manifest.d.ts +10 -0
  118. package/studio/capability-manifest.d.ts.map +1 -1
  119. package/studio/capability-manifest.js +38 -0
  120. package/studio/command-adapter.d.ts +35 -0
  121. package/studio/command-adapter.d.ts.map +1 -0
  122. package/studio/command-adapter.js +36 -0
  123. package/studio/generated/studio-api.d.ts +1062 -0
  124. package/studio/generated/studio-api.d.ts.map +1 -0
  125. package/studio/generated/studio-api.js +4 -0
  126. package/studio/index.d.ts +8 -6
  127. package/studio/index.d.ts.map +1 -1
  128. package/studio/index.js +6 -5
  129. package/studio/lifecycle-client.d.ts +3 -3
  130. package/studio/lifecycle-client.d.ts.map +1 -1
  131. package/studio/lifecycle-client.js +41 -22
  132. package/studio/lifecycle-types.d.ts +56 -77
  133. package/studio/lifecycle-types.d.ts.map +1 -1
  134. package/studio/lifecycle-types.js +5 -12
  135. package/studio/types.d.ts +37 -7
  136. package/studio/types.d.ts.map +1 -1
  137. package/studio/types.js +5 -3
  138. package/studio/validate.d.ts.map +1 -1
  139. package/studio/validate.js +104 -7
  140. package/style/renderers.d.ts +6 -1
  141. package/style/renderers.d.ts.map +1 -1
  142. package/style/renderers.js +11 -6
  143. package/style/visual-variables.d.ts +43 -0
  144. package/style/visual-variables.d.ts.map +1 -0
  145. package/style/visual-variables.js +183 -0
  146. package/webmap/convert-layer.d.ts +2 -1
  147. package/webmap/convert-layer.d.ts.map +1 -1
  148. package/webmap/convert-layer.js +20 -3
  149. package/webmap/convert-renderer.d.ts +10 -3
  150. package/webmap/convert-renderer.d.ts.map +1 -1
  151. package/webmap/convert-renderer.js +190 -36
  152. package/webmap/index.d.ts +1 -0
  153. package/webmap/index.d.ts.map +1 -1
  154. package/webmap/parse.d.ts +2 -1
  155. package/webmap/parse.d.ts.map +1 -1
  156. package/webmap/parse.js +1 -1
@@ -1,5 +1,7 @@
1
1
  import { CompatEventBus, resolveCompatEventBus } from "./event-bus.js";
2
2
  import { FeatureFilterCompat } from "./feature-filter.js";
3
+ import { GraphicsLayerCompat } from "./graphics-layer.js";
4
+ import { coordinateToLonLat, lonLatFromUnknown, mountCompatMap, resolveViewContainer, } from "./map-view-mount.js";
3
5
  export class MapViewPopupCompat {
4
6
  visible;
5
7
  location;
@@ -444,11 +446,13 @@ export class MapViewCompat {
444
446
  container;
445
447
  loaded;
446
448
  loadStatus;
447
- center;
448
- zoom;
449
+ /** SceneView turns this off so a 2D canvas is not presented as a scene. */
450
+ mountRenderer = true;
451
+ centerValue;
452
+ zoomValue;
453
+ extentValue;
449
454
  scale;
450
455
  rotation;
451
- extent;
452
456
  constraints;
453
457
  padding;
454
458
  highlightOptions;
@@ -456,20 +460,25 @@ export class MapViewCompat {
456
460
  eventBus;
457
461
  popup;
458
462
  ui;
463
+ /** Esri `MapView.graphics`, the overlay collection `view.graphics.add` writes. */
464
+ graphics;
459
465
  eventListeners;
460
466
  watchListeners;
461
467
  layerViews;
462
- readyPromise;
468
+ loadPromise;
469
+ mapSurface;
470
+ painted = [];
471
+ watchedLayers = new Set();
463
472
  constructor(options = {}) {
464
473
  this.map = options.map;
465
474
  this.container = options.container;
466
475
  this.loaded = false;
467
476
  this.loadStatus = "not-loaded";
468
- this.center = options.center;
469
- this.zoom = options.zoom;
477
+ this.centerValue = options.center;
478
+ this.zoomValue = options.zoom;
470
479
  this.scale = options.scale;
471
480
  this.rotation = options.rotation;
472
- this.extent = options.extent;
481
+ this.extentValue = options.extent;
473
482
  this.constraints = options.constraints;
474
483
  this.padding = options.padding;
475
484
  this.highlightOptions = options.highlightOptions;
@@ -503,35 +512,334 @@ export class MapViewCompat {
503
512
  }, extractPopupOptions(options.popup));
504
513
  this.ui = new MapViewUiCompat(this.eventBus, (components) => {
505
514
  this.notifyWatchers("ui.components", components);
515
+ this.placeUi(components);
516
+ });
517
+ this.graphics = new GraphicsLayerCompat({ id: "view-graphics", title: "Graphics", eventBus: this.eventBus });
518
+ this.graphics.eventBus.onAny((event) => {
519
+ if (event.type.startsWith("graphics-layer.")) {
520
+ void this.refreshOverlays();
521
+ }
506
522
  });
507
523
  this.eventListeners = new Map();
508
524
  this.watchListeners = new Map();
509
525
  this.layerViews = new Map();
510
- this.readyPromise = Promise.resolve(this);
526
+ const mapBus = options.map?.eventBus;
527
+ mapBus?.on("map.layer-added", (event) => {
528
+ this.watchLayerPaint(event.payload?.layer);
529
+ void this.refreshOverlays();
530
+ });
531
+ mapBus?.on("map.layers-added", (event) => {
532
+ const layers = event.payload?.layers ?? [];
533
+ for (const layer of layers) {
534
+ this.watchLayerPaint(layer);
535
+ }
536
+ void this.refreshOverlays();
537
+ });
538
+ queueMicrotask(() => {
539
+ if (this.mountRenderer && this.loadStatus === "not-loaded") {
540
+ void this.load();
541
+ }
542
+ });
543
+ }
544
+ get center() {
545
+ return this.centerValue;
546
+ }
547
+ set center(value) {
548
+ this.setCenter(value);
549
+ }
550
+ get zoom() {
551
+ return this.zoomValue;
552
+ }
553
+ set zoom(value) {
554
+ this.setZoom(value);
555
+ }
556
+ get extent() {
557
+ return this.extentValue;
558
+ }
559
+ set extent(value) {
560
+ if (value) {
561
+ this.setExtent(value);
562
+ }
563
+ }
564
+ /** Esri `view.ready`. True once {@link load} has finished. */
565
+ get ready() {
566
+ return this.loaded;
567
+ }
568
+ load() {
569
+ if (!this.loadPromise) {
570
+ const pending = this.performLoad();
571
+ // `void view.when()` starts this promise and does not await it.
572
+ // Awaiters still receive the rejection. This handler only keeps a
573
+ // background start from becoming an uncaught page error.
574
+ void pending.catch(() => undefined);
575
+ this.loadPromise = pending;
576
+ }
577
+ return this.loadPromise;
511
578
  }
512
- async load() {
579
+ async performLoad() {
513
580
  if (this.loaded) {
514
581
  return this;
515
582
  }
516
583
  this.loadStatus = "loading";
517
584
  this.notifyWatchers("loadStatus", this.loadStatus);
518
585
  this.eventBus.emit("view.loading", undefined, this);
519
- await this.readyPromise;
520
- this.loaded = true;
521
- this.notifyWatchers("loaded", this.loaded);
522
- this.loadStatus = "loaded";
523
- this.notifyWatchers("loadStatus", this.loadStatus);
524
- this.eventBus.emit("view.loaded", undefined, this);
525
- return this;
586
+ try {
587
+ const mapWithLoad = this.map;
588
+ if (mapWithLoad && typeof mapWithLoad.load === "function") {
589
+ await mapWithLoad.load();
590
+ }
591
+ this.applyWebMapViewpoint();
592
+ await this.mountSurface();
593
+ await this.ensureLayerViews();
594
+ await this.refreshOverlays();
595
+ this.placeUi(this.ui.components);
596
+ this.loaded = true;
597
+ this.notifyWatchers("loaded", this.loaded);
598
+ this.loadStatus = "loaded";
599
+ this.notifyWatchers("loadStatus", this.loadStatus);
600
+ this.eventBus.emit("view.loaded", undefined, this);
601
+ this.emit("arcgisViewReadyChange", { target: this });
602
+ return this;
603
+ }
604
+ catch (error) {
605
+ this.loaded = false;
606
+ this.loadStatus = "failed";
607
+ this.notifyWatchers("loadStatus", this.loadStatus);
608
+ this.loadPromise = undefined;
609
+ this.eventBus.emit("view.load-error", { error }, this);
610
+ throw error;
611
+ }
612
+ }
613
+ addEventListener(type, listener) {
614
+ const callback = typeof listener === "function" ? listener : (event) => listener.handleEvent(event);
615
+ this.on(type, callback);
616
+ }
617
+ removeEventListener(type, listener) {
618
+ this.eventListeners.get(type)?.delete(listener);
619
+ }
620
+ async mountSurface() {
621
+ if (!this.mountRenderer) {
622
+ return;
623
+ }
624
+ const container = resolveViewContainer(this.container);
625
+ if (!container) {
626
+ return;
627
+ }
628
+ const basemap = this.map?.basemap;
629
+ const surface = await mountCompatMap(container, lonLatFromUnknown(this.centerValue), this.zoomValue, basemap);
630
+ if (!surface) {
631
+ throw new Error("The map renderer did not start. Install maplibre-gl in a browser view container.");
632
+ }
633
+ this.mapSurface = surface;
634
+ surface.onClick((event) => {
635
+ void this.handleMapClick(event);
636
+ });
637
+ if (this.extentValue && this.centerValue === undefined) {
638
+ surface.fitExtent(this.extentValue);
639
+ }
640
+ }
641
+ applyWebMapViewpoint() {
642
+ if (this.centerValue !== undefined || this.extentValue !== undefined) {
643
+ return;
644
+ }
645
+ const initialExtent = this.map?.initialExtent;
646
+ if (initialExtent) {
647
+ this.extentValue = initialExtent;
648
+ }
649
+ }
650
+ async ensureLayerViews() {
651
+ const layers = this.map?.layers ?? [];
652
+ for (const layer of layers) {
653
+ this.watchLayerPaint(layer);
654
+ await this.whenLayerView(layer);
655
+ }
656
+ }
657
+ watchLayerPaint(layer) {
658
+ if (!layer || typeof layer !== "object" || this.watchedLayers.has(layer)) {
659
+ return;
660
+ }
661
+ this.watchedLayers.add(layer);
662
+ const bus = layer.eventBus;
663
+ if (!bus || typeof bus.on !== "function") {
664
+ return;
665
+ }
666
+ for (const type of [
667
+ "graphics-layer.graphic-added",
668
+ "graphics-layer.graphics-added",
669
+ "graphics-layer.graphic-removed",
670
+ "graphics-layer.graphics-cleared",
671
+ "feature-layer.edits",
672
+ ]) {
673
+ bus.on(type, () => {
674
+ void this.refreshOverlays();
675
+ });
676
+ }
677
+ }
678
+ async refreshOverlays() {
679
+ if (!this.mapSurface) {
680
+ return;
681
+ }
682
+ const drawn = [...this.graphics.graphics];
683
+ const layers = this.map?.layers ?? [];
684
+ for (const layer of layers) {
685
+ if (!layer || typeof layer !== "object") {
686
+ continue;
687
+ }
688
+ const record = layer;
689
+ if (record.visible === false) {
690
+ continue;
691
+ }
692
+ if (Array.isArray(record.graphics)) {
693
+ drawn.push(...record.graphics);
694
+ if (record.type === "graphics" ||
695
+ record.type === "graphics-layer" ||
696
+ typeof record.queryFeatures !== "function") {
697
+ continue;
698
+ }
699
+ }
700
+ if (typeof record.queryFeatures !== "function") {
701
+ continue;
702
+ }
703
+ try {
704
+ const result = await record.queryFeatures({
705
+ where: record.definitionExpression ?? "1=1",
706
+ outFields: ["*"],
707
+ returnGeometry: true,
708
+ extraParams: { resultRecordCount: 2000 },
709
+ });
710
+ drawn.push(...(result?.features ?? []));
711
+ }
712
+ catch {
713
+ // An unsupported where or a service error leaves that layer off the canvas.
714
+ }
715
+ }
716
+ this.painted = drawn;
717
+ this.mapSurface.setOverlays(drawn);
526
718
  }
527
- async when(callback) {
528
- const view = await this.load();
529
- if (callback) {
530
- callback(view);
719
+ async handleMapClick(event) {
720
+ const mapPoint = {
721
+ x: event.longitude,
722
+ y: event.latitude,
723
+ longitude: event.longitude,
724
+ latitude: event.latitude,
725
+ spatialReference: { wkid: 4326 },
726
+ };
727
+ this.emit("click", { ...event, mapPoint });
728
+ const hit = await this.hitTest({ x: event.x, y: event.y, mapPoint });
729
+ const graphic = hit.results[0]?.graphic;
730
+ if (!graphic || typeof graphic !== "object") {
731
+ return;
531
732
  }
532
- return view;
733
+ const record = graphic;
734
+ const title = record.popupTemplate?.title ??
735
+ (typeof record.attributes?.name === "string" ? record.attributes.name : undefined) ??
736
+ "Feature";
737
+ this.openPopup({ location: mapPoint, features: [graphic], title });
738
+ this.renderPopup(event.x, event.y, title, record.attributes);
739
+ }
740
+ renderPopup(x, y, title, attributes) {
741
+ const container = resolveViewContainer(this.container);
742
+ if (!container || typeof document === "undefined") {
743
+ return;
744
+ }
745
+ container.querySelector(":scope > .honua-popup")?.remove();
746
+ const popup = document.createElement("div");
747
+ popup.className = "honua-popup";
748
+ popup.style.position = "absolute";
749
+ popup.style.left = `${x}px`;
750
+ popup.style.top = `${y}px`;
751
+ popup.style.transform = "translate(-50%, -100%)";
752
+ popup.style.background = "#fff";
753
+ popup.style.padding = "8px";
754
+ popup.style.maxWidth = "240px";
755
+ const heading = document.createElement("strong");
756
+ heading.textContent = title;
757
+ popup.append(heading);
758
+ if (attributes) {
759
+ const list = document.createElement("ul");
760
+ for (const [key, value] of Object.entries(attributes)) {
761
+ if (key === "color" || key === "radius" || key === "width") {
762
+ continue;
763
+ }
764
+ const item = document.createElement("li");
765
+ item.textContent = `${key}: ${String(value)}`;
766
+ list.append(item);
767
+ }
768
+ popup.append(list);
769
+ }
770
+ container.append(popup);
771
+ }
772
+ placeUi(components) {
773
+ const container = resolveViewContainer(this.container);
774
+ if (!container || typeof document === "undefined") {
775
+ return;
776
+ }
777
+ const existing = container.querySelector(":scope > .honua-view-ui");
778
+ const host = typeof HTMLElement !== "undefined" && existing instanceof HTMLElement ? existing : document.createElement("div");
779
+ if (host.parentElement !== container) {
780
+ host.className = "honua-view-ui";
781
+ host.style.position = "absolute";
782
+ host.style.inset = "0";
783
+ host.style.pointerEvents = "none";
784
+ container.append(host);
785
+ }
786
+ host.replaceChildren();
787
+ for (const record of components) {
788
+ const slot = document.createElement("div");
789
+ slot.style.position = "absolute";
790
+ slot.style.pointerEvents = "auto";
791
+ const position = record.position;
792
+ if (position.includes("bottom")) {
793
+ slot.style.bottom = "12px";
794
+ }
795
+ else {
796
+ slot.style.top = "12px";
797
+ }
798
+ if (position.includes("right")) {
799
+ slot.style.right = "12px";
800
+ }
801
+ else if (!position.includes("bottom") || position.includes("left") || position === "manual") {
802
+ slot.style.left = "12px";
803
+ }
804
+ const widget = record.component;
805
+ if (widget && typeof widget === "object" && "attachContainer" in widget) {
806
+ const attach = widget.attachContainer;
807
+ if (typeof attach === "function") {
808
+ attach.call(widget, slot);
809
+ }
810
+ }
811
+ else if (typeof HTMLElement !== "undefined" && widget instanceof HTMLElement) {
812
+ slot.append(widget);
813
+ }
814
+ const load = widget?.load;
815
+ if (typeof load === "function") {
816
+ void load.call(widget);
817
+ }
818
+ host.append(slot);
819
+ }
820
+ }
821
+ when(callback) {
822
+ const pending = this.load().then((view) => {
823
+ if (callback) {
824
+ callback(view);
825
+ }
826
+ return view;
827
+ });
828
+ // Same as load(): a discarded `void view.when()` must not become a page error.
829
+ void pending.catch(() => undefined);
830
+ return pending;
533
831
  }
534
832
  toMap(screenPoint) {
833
+ const geographic = this.mapSurface?.unproject(screenPoint.x, screenPoint.y);
834
+ if (geographic) {
835
+ return {
836
+ x: geographic.longitude,
837
+ y: geographic.latitude,
838
+ longitude: geographic.longitude,
839
+ latitude: geographic.latitude,
840
+ spatialReference: { wkid: 4326 },
841
+ };
842
+ }
535
843
  const mapPoint = {
536
844
  x: screenPoint.x,
537
845
  y: screenPoint.y,
@@ -542,6 +850,14 @@ export class MapViewCompat {
542
850
  return mapPoint;
543
851
  }
544
852
  toScreen(mapPoint) {
853
+ const longitude = mapPoint.longitude ?? mapPoint.x;
854
+ const latitude = mapPoint.latitude ?? mapPoint.y;
855
+ const projected = typeof longitude === "number" && typeof latitude === "number"
856
+ ? this.mapSurface?.project(longitude, latitude)
857
+ : undefined;
858
+ if (projected) {
859
+ return projected;
860
+ }
545
861
  return {
546
862
  x: mapPoint.x,
547
863
  y: mapPoint.y,
@@ -550,6 +866,10 @@ export class MapViewCompat {
550
866
  async hitTest(event = {}) {
551
867
  const mapPoint = event.mapPoint ??
552
868
  (typeof event.x === "number" && typeof event.y === "number" ? this.toMap({ x: event.x, y: event.y }) : undefined);
869
+ const graphicHits = this.graphicsNear(mapPoint, event);
870
+ if (graphicHits.length > 0) {
871
+ return { results: graphicHits };
872
+ }
553
873
  return {
554
874
  results: this.popup.features.map((feature) => ({
555
875
  type: "graphic",
@@ -559,6 +879,41 @@ export class MapViewCompat {
559
879
  })),
560
880
  };
561
881
  }
882
+ graphicsNear(mapPoint, event) {
883
+ if (!mapPoint) {
884
+ return [];
885
+ }
886
+ const target = lonLatFromUnknown(mapPoint);
887
+ if (!target) {
888
+ return [];
889
+ }
890
+ const candidates = [...this.painted, ...this.graphics.graphics];
891
+ for (const layer of this.map?.layers ?? []) {
892
+ const record = layer;
893
+ if (Array.isArray(record?.graphics)) {
894
+ candidates.push(...record.graphics);
895
+ }
896
+ if (Array.isArray(record?.source)) {
897
+ candidates.push(...record.source);
898
+ }
899
+ }
900
+ const hits = [];
901
+ for (const graphic of candidates) {
902
+ if (!graphic || typeof graphic !== "object") {
903
+ continue;
904
+ }
905
+ if (!graphicHitsTarget(graphic, target, event, this.mapSurface)) {
906
+ continue;
907
+ }
908
+ hits.push({
909
+ type: "graphic",
910
+ graphic: graphic,
911
+ layer: extractGraphicLayer(graphic),
912
+ mapPoint,
913
+ });
914
+ }
915
+ return hits;
916
+ }
562
917
  async goTo(target, options = {}) {
563
918
  const normalizedTarget = normalizeGoToTarget(target);
564
919
  if (normalizedTarget.center !== undefined) {
@@ -611,14 +966,18 @@ export class MapViewCompat {
611
966
  this.popup.close();
612
967
  }
613
968
  setCenter(center) {
614
- this.center = center;
615
- this.notifyWatchers("center", this.center);
969
+ this.centerValue = center;
970
+ this.notifyWatchers("center", this.centerValue);
616
971
  this.eventBus.emit("view.center-changed", { center }, this);
972
+ if (center) {
973
+ this.mapSurface?.setView(lonLatFromUnknown(center), this.zoomValue);
974
+ }
617
975
  }
618
976
  setZoom(zoom) {
619
- this.zoom = zoom;
620
- this.notifyWatchers("zoom", this.zoom);
977
+ this.zoomValue = zoom;
978
+ this.notifyWatchers("zoom", this.zoomValue);
621
979
  this.eventBus.emit("view.zoom-changed", { zoom }, this);
980
+ this.mapSurface?.setView(lonLatFromUnknown(this.centerValue), zoom);
622
981
  }
623
982
  setScale(scale) {
624
983
  this.scale = scale;
@@ -631,9 +990,10 @@ export class MapViewCompat {
631
990
  this.eventBus.emit("view.rotation-changed", { rotation }, this);
632
991
  }
633
992
  setExtent(extent) {
634
- this.extent = extent;
635
- this.notifyWatchers("extent", this.extent);
993
+ this.extentValue = extent;
994
+ this.notifyWatchers("extent", this.extentValue);
636
995
  this.eventBus.emit("view.extent-changed", { extent }, this);
996
+ this.mapSurface?.fitExtent(extent);
637
997
  }
638
998
  setPadding(padding) {
639
999
  this.padding = padding;
@@ -706,6 +1066,8 @@ export class MapViewCompat {
706
1066
  };
707
1067
  }
708
1068
  destroy() {
1069
+ this.mapSurface?.destroy();
1070
+ this.mapSurface = undefined;
709
1071
  this.eventBus.emit("view.destroy", undefined, this);
710
1072
  this.emit("destroy", undefined);
711
1073
  this.ui.removeAll();
@@ -719,16 +1081,16 @@ export class MapViewCompat {
719
1081
  this.notifyWatchers("map", this.map);
720
1082
  this.container = undefined;
721
1083
  this.notifyWatchers("container", this.container);
722
- this.center = undefined;
723
- this.notifyWatchers("center", this.center);
724
- this.zoom = undefined;
725
- this.notifyWatchers("zoom", this.zoom);
1084
+ this.centerValue = undefined;
1085
+ this.notifyWatchers("center", this.centerValue);
1086
+ this.zoomValue = undefined;
1087
+ this.notifyWatchers("zoom", this.zoomValue);
726
1088
  this.scale = undefined;
727
1089
  this.notifyWatchers("scale", this.scale);
728
1090
  this.rotation = undefined;
729
1091
  this.notifyWatchers("rotation", this.rotation);
730
- this.extent = undefined;
731
- this.notifyWatchers("extent", this.extent);
1092
+ this.extentValue = undefined;
1093
+ this.notifyWatchers("extent", this.extentValue);
732
1094
  this.constraints = undefined;
733
1095
  this.notifyWatchers("constraints", this.constraints);
734
1096
  this.padding = undefined;
@@ -1137,6 +1499,78 @@ function extractObjectId(feature) {
1137
1499
  function normalizeCount(value) {
1138
1500
  return typeof value === "number" && Number.isFinite(value) ? value : 0;
1139
1501
  }
1502
+ function graphicHitsTarget(graphic, target, event, surface) {
1503
+ const geometry = graphic.geometry;
1504
+ if (!geometry || typeof geometry !== "object") {
1505
+ return false;
1506
+ }
1507
+ const record = geometry;
1508
+ const point = record.rings === undefined && record.paths === undefined ? lonLatFromUnknown(geometry) : undefined;
1509
+ if (point && nearLonLat(point, target, event, surface)) {
1510
+ return true;
1511
+ }
1512
+ const wkid = record.spatialReference?.wkid;
1513
+ if (Array.isArray(record.rings)) {
1514
+ return record.rings.some((ring) => Array.isArray(ring) && pointInRing(target, ring, wkid));
1515
+ }
1516
+ if (Array.isArray(record.paths)) {
1517
+ for (const path of record.paths) {
1518
+ if (!Array.isArray(path)) {
1519
+ continue;
1520
+ }
1521
+ for (const pair of path) {
1522
+ if (!Array.isArray(pair)) {
1523
+ continue;
1524
+ }
1525
+ const vertex = coordinateToLonLat(pair, wkid);
1526
+ if (vertex && nearLonLat(vertex, target, event, surface)) {
1527
+ return true;
1528
+ }
1529
+ }
1530
+ }
1531
+ }
1532
+ return false;
1533
+ }
1534
+ function nearLonLat(point, target, event, surface) {
1535
+ const geographicNear = Math.abs(point[0] - target[0]) <= 0.0005 && Math.abs(point[1] - target[1]) <= 0.0005;
1536
+ const projected = surface?.project(point[0], point[1]);
1537
+ const pixelNear = projected !== undefined &&
1538
+ typeof event.x === "number" &&
1539
+ typeof event.y === "number" &&
1540
+ Math.hypot(projected.x - event.x, projected.y - event.y) <= 12;
1541
+ return geographicNear || pixelNear;
1542
+ }
1543
+ function pointInRing(target, ring, wkid) {
1544
+ const polygon = [];
1545
+ for (const pair of ring) {
1546
+ if (!Array.isArray(pair)) {
1547
+ continue;
1548
+ }
1549
+ const lonLat = coordinateToLonLat(pair, wkid);
1550
+ if (lonLat) {
1551
+ polygon.push(lonLat);
1552
+ }
1553
+ }
1554
+ if (polygon.length < 3) {
1555
+ return false;
1556
+ }
1557
+ let inside = false;
1558
+ for (let index = 0, previous = polygon.length - 1; index < polygon.length; previous = index, index += 1) {
1559
+ const current = polygon[index];
1560
+ const earlier = polygon[previous];
1561
+ if (!current || !earlier) {
1562
+ continue;
1563
+ }
1564
+ const crosses = current[1] > target[1] !== earlier[1] > target[1] &&
1565
+ target[0] <
1566
+ ((earlier[0] - current[0]) * (target[1] - current[1])) / (earlier[1] - current[1] + Number.EPSILON) +
1567
+ current[0];
1568
+ if (crosses) {
1569
+ inside = !inside;
1570
+ }
1571
+ }
1572
+ return inside;
1573
+ }
1140
1574
  function extractGraphicLayer(value) {
1141
1575
  if (!("layer" in value) || value.layer === undefined || value.layer === null) {
1142
1576
  return undefined;
@@ -177,6 +177,8 @@ export declare class PortalCompat {
177
177
  search(options?: PortalSearchOptions): Promise<PortalSearchResult>;
178
178
  /** `GET /sharing/rest/content/items/{id}`. */
179
179
  getItem(itemId: string, options?: PortalGetItemOptions): Promise<PortalItem>;
180
+ /** `GET /sharing/rest/content/items/{id}/data`. Web maps return their operational layers here. */
181
+ getItemData(itemId: string, options?: PortalGetItemOptions): Promise<unknown>;
180
182
  /**
181
183
  * Resolve an item (fetching it when given an id), parse its service `url`, and
182
184
  * return an authenticated handle. Feature Service items yield a
@@ -1 +1 @@
1
- {"version":3,"file":"portal.d.ts","sourceRoot":"","sources":["../../../src/esri-compat/portal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAA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AC;IAiBnF,8CAA8C;IACjC,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,UAAU,CAAC;IAI7F,kGAAkG;IACrF,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9F;;;;;OAKG;IACU,gBAAgB,CAC3B,QAAQ,EAAE,MAAM,GAAG,UAAU,EAC7B,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,gBAAgB,CAAC;IAiD5B;;;;OAIG;IACI,2BAA2B,IAAI,IAAI;IAW1C,OAAO,CAAC,wBAAwB;YAalB,OAAO;CAqBtB"}
@@ -116,6 +116,10 @@ export class PortalCompat {
116
116
  async getItem(itemId, options = {}) {
117
117
  return this.getJson(`/content/items/${encodeURIComponent(itemId)}`, {}, options.token ?? this.token);
118
118
  }
119
+ /** `GET /sharing/rest/content/items/{id}/data`. Web maps return their operational layers here. */
120
+ async getItemData(itemId, options = {}) {
121
+ return this.getJson(`/content/items/${encodeURIComponent(itemId)}/data`, {}, options.token ?? this.token);
122
+ }
119
123
  /**
120
124
  * Resolve an item (fetching it when given an id), parse its service `url`, and
121
125
  * return an authenticated handle. Feature Service items yield a
@@ -203,8 +207,9 @@ export class PortalCompat {
203
207
  query.set(key, String(value));
204
208
  }
205
209
  }
206
- if (token) {
207
- query.set("token", token);
210
+ const authToken = token ?? this.apiKey ?? identityManager.findCredential(this.sharingRestBase)?.token;
211
+ if (authToken) {
212
+ query.set("token", authToken);
208
213
  }
209
214
  const response = await this.fetchFn(`${this.sharingRestBase}${path}?${query.toString()}`);
210
215
  const json = (await response.json());