@acorex/components 19.15.0-next.3 → 19.15.0-next.5
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.
- package/fesm2022/acorex-components-button.mjs +4 -4
- package/fesm2022/acorex-components-button.mjs.map +1 -1
- package/fesm2022/acorex-components-conversation.mjs +2 -2
- package/fesm2022/acorex-components-conversation.mjs.map +1 -1
- package/fesm2022/acorex-components-grid-layout-builder.mjs +3 -3
- package/fesm2022/acorex-components-grid-layout-builder.mjs.map +1 -1
- package/fesm2022/acorex-components-map.mjs +253 -97
- package/fesm2022/acorex-components-map.mjs.map +1 -1
- package/fesm2022/acorex-components-range-slider.mjs +2 -2
- package/fesm2022/acorex-components-range-slider.mjs.map +1 -1
- package/fesm2022/acorex-components-tag-box.mjs +2 -2
- package/fesm2022/acorex-components-tag-box.mjs.map +1 -1
- package/fesm2022/acorex-components-text-box.mjs +2 -2
- package/fesm2022/acorex-components-text-box.mjs.map +1 -1
- package/fesm2022/acorex-components-time-duration.mjs +22 -85
- package/fesm2022/acorex-components-time-duration.mjs.map +1 -1
- package/map/lib/map.component.d.ts +38 -11
- package/package.json +1 -1
- package/time-duration/lib/time-duration.component.d.ts +0 -4
@@ -496,34 +496,40 @@ class AXLeafletService {
|
|
496
496
|
* Adjusts the map view to fit all markers, polygons, and boundaries currently on the map.
|
497
497
|
*/
|
498
498
|
fitBoundsToDrawItems() {
|
499
|
-
if (!this.map
|
500
|
-
console.warn('Map
|
499
|
+
if (!this.map) {
|
500
|
+
console.warn('Map not initialized.');
|
501
501
|
return;
|
502
502
|
}
|
503
503
|
const bounds = this.L.latLngBounds([]);
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
504
|
+
let hasValidBounds = false;
|
505
|
+
// Add all draw items to bounds if they exist
|
506
|
+
if (this.drawnItems) {
|
507
|
+
this.drawnItems.getLayers().forEach((layer) => {
|
508
|
+
if (layer instanceof this.L.Marker) {
|
509
|
+
bounds.extend(layer.getLatLng());
|
510
|
+
hasValidBounds = true;
|
511
|
+
}
|
512
|
+
else if (layer instanceof this.L.Polygon) {
|
513
|
+
const latLngs = layer.getLatLngs();
|
514
|
+
latLngs.forEach((latLngArray) => {
|
515
|
+
latLngArray.forEach((latLng) => {
|
516
|
+
bounds.extend(latLng);
|
517
|
+
hasValidBounds = true;
|
518
|
+
});
|
514
519
|
});
|
515
|
-
}
|
516
|
-
}
|
517
|
-
}
|
518
|
-
//
|
520
|
+
}
|
521
|
+
});
|
522
|
+
}
|
523
|
+
// Always include boundaries if set
|
519
524
|
if (this.boundary && this.boundary.length > 0) {
|
520
525
|
this.boundary.forEach((boundaryPolygon) => {
|
521
526
|
boundaryPolygon.points.forEach((point) => {
|
522
527
|
bounds.extend([point.latitude, point.longitude]);
|
528
|
+
hasValidBounds = true;
|
523
529
|
});
|
524
530
|
});
|
525
531
|
}
|
526
|
-
if (bounds.isValid()) {
|
532
|
+
if (hasValidBounds && bounds.isValid()) {
|
527
533
|
const maxZoom = 18;
|
528
534
|
this.map.fitBounds(bounds, {
|
529
535
|
padding: [20, 20],
|
@@ -654,13 +660,13 @@ class AXMapComponent {
|
|
654
660
|
this.hasLocator = input(false);
|
655
661
|
/**
|
656
662
|
* @description
|
657
|
-
*
|
663
|
+
* Whether map should contain all draw items.
|
658
664
|
* @default false
|
659
665
|
*/
|
660
666
|
this.fitToDraw = input(false);
|
661
667
|
/**
|
662
668
|
* @description
|
663
|
-
*
|
669
|
+
* Whether map draw has to limit in area.
|
664
670
|
* @default undefined
|
665
671
|
*/
|
666
672
|
this.limitDraw = input(undefined);
|
@@ -721,106 +727,138 @@ class AXMapComponent {
|
|
721
727
|
this.mapContainer = viewChild('mapContainer');
|
722
728
|
this.leafletService = inject(AXLeafletService);
|
723
729
|
this.rendered = signal(false);
|
730
|
+
/**
|
731
|
+
* Initialize the map once rendering is complete
|
732
|
+
*/
|
724
733
|
this.#initMap = afterNextRender(async () => {
|
725
734
|
await this.leafletService.initMap(this.mapContainer().nativeElement, { latitude: this.latitude() ?? 31, longitude: this.longitude() ?? 51 }, this.zoomLevel() ?? 5);
|
735
|
+
// Initialize map data
|
726
736
|
if (this.markers()) {
|
727
737
|
this.leafletService.addMarker(this.markers());
|
728
738
|
}
|
729
739
|
if (this.polygons()) {
|
730
740
|
this.leafletService.addPolygon(this.polygons());
|
731
741
|
}
|
732
|
-
if (this.fitToDraw() && (this.polygons() || this.markers())) {
|
733
|
-
this.leafletService.fitBoundsToDrawItems();
|
734
|
-
}
|
735
742
|
if (this.limitDraw()) {
|
736
743
|
this.leafletService.setBoundary(this.limitDraw());
|
737
744
|
}
|
745
|
+
// Setup map events
|
746
|
+
this.setupMapEvents();
|
747
|
+
// Apply initial fit if needed
|
748
|
+
if (this.fitToDraw()) {
|
749
|
+
this.leafletService.fitBoundsToDrawItems();
|
750
|
+
}
|
738
751
|
this.onMapReady.emit();
|
739
752
|
this.rendered.set(true);
|
740
753
|
});
|
754
|
+
/**
|
755
|
+
* Effect for locator control
|
756
|
+
*/
|
741
757
|
this.#locatorEffect = effect(() => {
|
742
|
-
if (this.rendered())
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
this.leafletService.addLocateControl(this.locatePlace());
|
752
|
-
if (!this.onLocationFoundSubscription) {
|
753
|
-
this.onLocationFoundSubscription = this.leafletService.onLocationFound
|
754
|
-
.pipe(distinctUntilChanged((prev, curr) => prev.latitude === curr.latitude && prev.longitude === curr.longitude))
|
755
|
-
.subscribe((location) => {
|
756
|
-
this.onLocationFound.emit(location);
|
757
|
-
});
|
758
|
-
}
|
758
|
+
if (!this.rendered())
|
759
|
+
return;
|
760
|
+
const hasLocator = this.hasLocator();
|
761
|
+
const locatePlace = this.locatePlace();
|
762
|
+
if (!hasLocator) {
|
763
|
+
this.leafletService.removeLocateControl();
|
764
|
+
if (this.onLocationFoundSubscription) {
|
765
|
+
this.onLocationFoundSubscription.unsubscribe();
|
766
|
+
this.onLocationFoundSubscription = undefined;
|
759
767
|
}
|
768
|
+
return;
|
760
769
|
}
|
761
|
-
|
762
|
-
|
763
|
-
if
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
this.
|
769
|
-
});
|
770
|
-
this.leafletService.onZoomChanged.subscribe((zoom) => {
|
771
|
-
this.zoomLevel.set(zoom);
|
770
|
+
// Add locator control
|
771
|
+
this.leafletService.addLocateControl(locatePlace);
|
772
|
+
// Subscribe to location events if not already subscribed
|
773
|
+
if (!this.onLocationFoundSubscription) {
|
774
|
+
this.onLocationFoundSubscription = this.leafletService.onLocationFound
|
775
|
+
.pipe(distinctUntilChanged((prev, curr) => prev.latitude === curr.latitude && prev.longitude === curr.longitude))
|
776
|
+
.subscribe((location) => {
|
777
|
+
this.onLocationFound.emit(location);
|
772
778
|
});
|
773
|
-
if (!this.hasDraw()) {
|
774
|
-
this.leafletService.removeDrawControl();
|
775
|
-
this.unsubscribeFromEvents();
|
776
|
-
}
|
777
|
-
else {
|
778
|
-
this.leafletService.addDrawControl(this.markerPlace(), this.maxMarker() || 1, this.maxPolygon());
|
779
|
-
if (!this.onMarkerChangedSubscription) {
|
780
|
-
this.onMarkerChangedSubscription = this.leafletService.onMarkerChanged.subscribe((location) => {
|
781
|
-
this.onMarkerChanged.emit(location);
|
782
|
-
});
|
783
|
-
}
|
784
|
-
if (!this.onMarkerAddedSubscription) {
|
785
|
-
this.onMarkerAddedSubscription = this.leafletService.onMarkerAdded.subscribe((location) => {
|
786
|
-
this.onMarkerAdded.emit(location);
|
787
|
-
});
|
788
|
-
}
|
789
|
-
if (!this.onPolygonChangedSubscription) {
|
790
|
-
this.onPolygonChangedSubscription = this.leafletService.onPolygonChanged.subscribe((location) => {
|
791
|
-
this.onPolygonChanged.emit(location);
|
792
|
-
});
|
793
|
-
}
|
794
|
-
if (!this.onPolygonAddedSubscription) {
|
795
|
-
this.onPolygonAddedSubscription = this.leafletService.onPolygonAdded.subscribe((location) => {
|
796
|
-
this.onPolygonAdded.emit(location);
|
797
|
-
});
|
798
|
-
}
|
799
|
-
}
|
800
779
|
}
|
801
780
|
});
|
781
|
+
/**
|
782
|
+
* Effect for draw control
|
783
|
+
*/
|
784
|
+
this.#drawControlEffect = effect(() => {
|
785
|
+
if (!this.rendered())
|
786
|
+
return;
|
787
|
+
const hasDraw = this.hasDraw();
|
788
|
+
const markerPlace = this.markerPlace();
|
789
|
+
const maxMarker = this.maxMarker();
|
790
|
+
const maxPolygon = this.maxPolygon();
|
791
|
+
if (!hasDraw) {
|
792
|
+
this.leafletService.removeDrawControl();
|
793
|
+
this.unsubscribeFromDrawEvents();
|
794
|
+
return;
|
795
|
+
}
|
796
|
+
// Add draw control with current settings
|
797
|
+
this.leafletService.addDrawControl(markerPlace, maxMarker || 1, maxPolygon);
|
798
|
+
// Set up event subscriptions
|
799
|
+
this.setupDrawEventSubscriptions();
|
800
|
+
});
|
801
|
+
/**
|
802
|
+
* Effect for zoom level changes
|
803
|
+
*/
|
802
804
|
this.#zoomEffect = effect(() => {
|
803
805
|
if (this.rendered() && this.zoomLevel() !== null) {
|
804
806
|
this.leafletService.setZoomLevel(this.zoomLevel());
|
805
807
|
}
|
806
808
|
});
|
809
|
+
/**
|
810
|
+
* Effect for limit draw changes
|
811
|
+
*/
|
807
812
|
this.#limitDrawEffect = effect(() => {
|
808
|
-
if (this.rendered()
|
813
|
+
if (!this.rendered())
|
814
|
+
return;
|
815
|
+
const limitDraw = this.limitDraw();
|
816
|
+
if (limitDraw) {
|
809
817
|
this.leafletService.removeBoundary();
|
810
|
-
this.leafletService.setBoundary(
|
818
|
+
this.leafletService.setBoundary(limitDraw);
|
819
|
+
if (this.fitToDraw()) {
|
820
|
+
this.fitBoundsToDrawItems();
|
821
|
+
}
|
811
822
|
}
|
812
823
|
});
|
824
|
+
/**
|
825
|
+
* Effect for markers changes
|
826
|
+
*/
|
827
|
+
this.#markersEffect = effect(() => {
|
828
|
+
if (this.rendered() && this.markers() && this.fitToDraw()) {
|
829
|
+
this.fitBoundsToDrawItems();
|
830
|
+
}
|
831
|
+
});
|
832
|
+
/**
|
833
|
+
* Effect for polygons changes
|
834
|
+
*/
|
835
|
+
this.#polygonsEffect = effect(() => {
|
836
|
+
if (this.rendered() && this.polygons() && this.fitToDraw()) {
|
837
|
+
this.fitBoundsToDrawItems();
|
838
|
+
}
|
839
|
+
});
|
840
|
+
/**
|
841
|
+
* Effect for fitToDraw changes
|
842
|
+
*/
|
843
|
+
this.#fitToDrawEffect = effect(() => {
|
844
|
+
if (this.rendered() && this.fitToDraw()) {
|
845
|
+
this.fitBoundsToDrawItems();
|
846
|
+
}
|
847
|
+
});
|
848
|
+
/**
|
849
|
+
* Effect for center changes (lat/long)
|
850
|
+
*/
|
813
851
|
this.#centerEffect = effect(() => {
|
814
|
-
if (this.rendered())
|
815
|
-
|
816
|
-
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
821
|
-
|
822
|
-
this.
|
823
|
-
}
|
852
|
+
if (!this.rendered())
|
853
|
+
return;
|
854
|
+
if (this.fitToDraw()) {
|
855
|
+
this.fitBoundsToDrawItems();
|
856
|
+
}
|
857
|
+
else {
|
858
|
+
this.leafletService.setCenter({
|
859
|
+
latitude: this.latitude(),
|
860
|
+
longitude: this.longitude(),
|
861
|
+
});
|
824
862
|
}
|
825
863
|
});
|
826
864
|
}
|
@@ -832,6 +870,12 @@ class AXMapComponent {
|
|
832
870
|
addMarker(location) {
|
833
871
|
this.leafletService.addMarker(location);
|
834
872
|
}
|
873
|
+
/**
|
874
|
+
* @description
|
875
|
+
* Adds a polygon to the specified location on the map.
|
876
|
+
* @param location - The location where the polygon should be placed.
|
877
|
+
* @param clickCallback - Optional callback for polygon click events.
|
878
|
+
*/
|
835
879
|
addPolygon(location, clickCallback) {
|
836
880
|
this.leafletService.addPolygon(location, clickCallback);
|
837
881
|
}
|
@@ -878,9 +922,18 @@ class AXMapComponent {
|
|
878
922
|
fitBoundsToDrawItems() {
|
879
923
|
return this.leafletService.fitBoundsToDrawItems();
|
880
924
|
}
|
925
|
+
/**
|
926
|
+
* @description
|
927
|
+
* Sets the boundary limit for drawing
|
928
|
+
* @param data - The polygon data defining the boundary
|
929
|
+
*/
|
881
930
|
setLimitDraw(data) {
|
882
931
|
return this.leafletService.setBoundary(data);
|
883
932
|
}
|
933
|
+
/**
|
934
|
+
* @description
|
935
|
+
* Removes the boundary limit for drawing
|
936
|
+
*/
|
884
937
|
removeLimitDraw() {
|
885
938
|
this.leafletService.removeBoundary();
|
886
939
|
}
|
@@ -896,35 +949,138 @@ class AXMapComponent {
|
|
896
949
|
flyTo(location, zoom, setMarker, duration) {
|
897
950
|
this.leafletService.flyTo(location, zoom, setMarker, duration);
|
898
951
|
}
|
952
|
+
/**
|
953
|
+
* Initialize the map once rendering is complete
|
954
|
+
*/
|
899
955
|
#initMap;
|
956
|
+
/**
|
957
|
+
* Setup map event listeners
|
958
|
+
*/
|
959
|
+
setupMapEvents() {
|
960
|
+
// Map movement events
|
961
|
+
this.onLatitudeChangedSubscription = this.leafletService.onLatitudeChanged.subscribe((latitude) => {
|
962
|
+
this.latitude.set(latitude);
|
963
|
+
});
|
964
|
+
this.onLongitudeChangedSubscription = this.leafletService.onLongitudeChanged.subscribe((longitude) => {
|
965
|
+
this.longitude.set(longitude);
|
966
|
+
});
|
967
|
+
this.onZoomChangedSubscription = this.leafletService.onZoomChanged.subscribe((zoom) => {
|
968
|
+
this.zoomLevel.set(zoom);
|
969
|
+
});
|
970
|
+
}
|
971
|
+
/**
|
972
|
+
* Effect for locator control
|
973
|
+
*/
|
900
974
|
#locatorEffect;
|
901
|
-
|
902
|
-
|
975
|
+
/**
|
976
|
+
* Effect for draw control
|
977
|
+
*/
|
978
|
+
#drawControlEffect;
|
979
|
+
/**
|
980
|
+
* Setup draw event subscriptions
|
981
|
+
*/
|
982
|
+
setupDrawEventSubscriptions() {
|
983
|
+
// Marker changed events
|
984
|
+
if (!this.onMarkerChangedSubscription) {
|
985
|
+
this.onMarkerChangedSubscription = this.leafletService.onMarkerChanged.subscribe((markers) => {
|
986
|
+
this.onMarkerChanged.emit(markers);
|
987
|
+
if (this.fitToDraw()) {
|
988
|
+
this.fitBoundsToDrawItems();
|
989
|
+
}
|
990
|
+
});
|
991
|
+
}
|
992
|
+
// Marker added events
|
993
|
+
if (!this.onMarkerAddedSubscription) {
|
994
|
+
this.onMarkerAddedSubscription = this.leafletService.onMarkerAdded.subscribe((marker) => {
|
995
|
+
this.onMarkerAdded.emit(marker);
|
996
|
+
if (this.fitToDraw()) {
|
997
|
+
this.fitBoundsToDrawItems();
|
998
|
+
}
|
999
|
+
});
|
1000
|
+
}
|
1001
|
+
// Polygon changed events
|
1002
|
+
if (!this.onPolygonChangedSubscription) {
|
1003
|
+
this.onPolygonChangedSubscription = this.leafletService.onPolygonChanged.subscribe((polygons) => {
|
1004
|
+
this.onPolygonChanged.emit(polygons);
|
1005
|
+
if (this.fitToDraw()) {
|
1006
|
+
this.fitBoundsToDrawItems();
|
1007
|
+
}
|
1008
|
+
});
|
1009
|
+
}
|
1010
|
+
// Polygon added events
|
1011
|
+
if (!this.onPolygonAddedSubscription) {
|
1012
|
+
this.onPolygonAddedSubscription = this.leafletService.onPolygonAdded.subscribe((polygon) => {
|
1013
|
+
this.onPolygonAdded.emit(polygon);
|
1014
|
+
if (this.fitToDraw()) {
|
1015
|
+
this.fitBoundsToDrawItems();
|
1016
|
+
}
|
1017
|
+
});
|
1018
|
+
}
|
1019
|
+
}
|
1020
|
+
/**
|
1021
|
+
* Unsubscribe from draw events
|
1022
|
+
*/
|
1023
|
+
unsubscribeFromDrawEvents() {
|
903
1024
|
if (this.onMarkerChangedSubscription) {
|
904
1025
|
this.onMarkerChangedSubscription.unsubscribe();
|
905
|
-
this.onMarkerChangedSubscription =
|
1026
|
+
this.onMarkerChangedSubscription = undefined;
|
906
1027
|
}
|
907
1028
|
if (this.onMarkerAddedSubscription) {
|
908
1029
|
this.onMarkerAddedSubscription.unsubscribe();
|
909
|
-
this.onMarkerAddedSubscription =
|
1030
|
+
this.onMarkerAddedSubscription = undefined;
|
910
1031
|
}
|
911
1032
|
if (this.onPolygonChangedSubscription) {
|
912
1033
|
this.onPolygonChangedSubscription.unsubscribe();
|
913
|
-
this.onPolygonChangedSubscription =
|
1034
|
+
this.onPolygonChangedSubscription = undefined;
|
914
1035
|
}
|
915
1036
|
if (this.onPolygonAddedSubscription) {
|
916
1037
|
this.onPolygonAddedSubscription.unsubscribe();
|
917
|
-
this.onPolygonAddedSubscription =
|
1038
|
+
this.onPolygonAddedSubscription = undefined;
|
918
1039
|
}
|
919
1040
|
}
|
1041
|
+
/**
|
1042
|
+
* Effect for zoom level changes
|
1043
|
+
*/
|
920
1044
|
#zoomEffect;
|
1045
|
+
/**
|
1046
|
+
* Effect for limit draw changes
|
1047
|
+
*/
|
921
1048
|
#limitDrawEffect;
|
1049
|
+
/**
|
1050
|
+
* Effect for markers changes
|
1051
|
+
*/
|
1052
|
+
#markersEffect;
|
1053
|
+
/**
|
1054
|
+
* Effect for polygons changes
|
1055
|
+
*/
|
1056
|
+
#polygonsEffect;
|
1057
|
+
/**
|
1058
|
+
* Effect for fitToDraw changes
|
1059
|
+
*/
|
1060
|
+
#fitToDrawEffect;
|
1061
|
+
/**
|
1062
|
+
* Effect for center changes (lat/long)
|
1063
|
+
*/
|
922
1064
|
#centerEffect;
|
923
1065
|
/**
|
924
|
-
*
|
925
|
-
* Cleanup function that destroys the map when the component is destroyed.
|
1066
|
+
* Cleanup function that destroys the map and unsubscribes from all subscriptions.
|
926
1067
|
*/
|
927
1068
|
ngOnDestroy() {
|
1069
|
+
// Unsubscribe from all subscriptions
|
1070
|
+
this.unsubscribeFromDrawEvents();
|
1071
|
+
if (this.onLocationFoundSubscription) {
|
1072
|
+
this.onLocationFoundSubscription.unsubscribe();
|
1073
|
+
}
|
1074
|
+
if (this.onLatitudeChangedSubscription) {
|
1075
|
+
this.onLatitudeChangedSubscription.unsubscribe();
|
1076
|
+
}
|
1077
|
+
if (this.onLongitudeChangedSubscription) {
|
1078
|
+
this.onLongitudeChangedSubscription.unsubscribe();
|
1079
|
+
}
|
1080
|
+
if (this.onZoomChangedSubscription) {
|
1081
|
+
this.onZoomChangedSubscription.unsubscribe();
|
1082
|
+
}
|
1083
|
+
// Destroy the map
|
928
1084
|
this.leafletService.destroyMap();
|
929
1085
|
}
|
930
1086
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "19.2.10", ngImport: i0, type: AXMapComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|