jmapcloud-ng-core-types 1.0.10 → 1.0.12

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/index.ts CHANGED
@@ -329,6 +329,8 @@ export interface JLayerEventModule extends JEventModule {
329
329
  sourceChange(listenerId: string, fn: (params: JLayerEventParams) => void): void
330
330
  selectabilityWillChange(listenerId: string, fn: (params: JLayerEventSelectabilityParams) => void): void
331
331
  layerDeletion(listenerId: string, fn: (params: JLayerEventParams) => void): void
332
+ thematicAddition(listenerId: string, fn: (params: JAddMapThematicEventParams) => void): void
333
+ thematicDeletion(listenerId: string, fn: (params: JLayerThematicEventParams) => void): void
332
334
  initialSearchApplied(listenerId: string, fn: (params: JLayerInitialSearchEventParams) => void): void
333
335
  dynamicFilterSet(listenerId: string, fn: (params: JLayerDynamicFilterSetParams) => void): void
334
336
  dynamicFilterActivationChange(listenerId: string, fn: (params: JLayerDynamicFilterActivationParams) => void): void
@@ -696,7 +698,8 @@ export interface JMapService {
696
698
  isTerrainAvailable(): boolean
697
699
  isTerrainActive(): boolean
698
700
  setTerrainActive(active: boolean): void
699
- setSelectionStyle(layerId: JId, style: JLayerSetSelectionStyleParam): void
701
+ setSelectionStyle(layerId: JId, style: JLayerSetStyleParams): void
702
+ resetSelectionStyle(layerId: JId): void
700
703
  setScaleControlVisibility(isVisible: boolean, position?: JMAP_POSITIONS): void
701
704
  setScaleControlUnits(units: "imperial" | "metric" | "nautical"): void
702
705
  setScaleControlPosition(position: JMAP_POSITIONS): void
@@ -896,6 +899,8 @@ export interface JLayerSearchService {
896
899
  }
897
900
 
898
901
  export interface JLayerThematicService {
902
+ addThematic(params: JLayerAddThematicParams): Promise<void>
903
+ deleteThematic(layerId: JId, thematicId: JId): void
899
904
  getAllByLayerId(layerId: JId): JLayerThematic[]
900
905
  getById(layerId: JId, thematicId: JId): JLayerThematic
901
906
  existsById(layerId: JId, thematicId: JId): boolean
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jmapcloud-ng-core-types",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "JMap Cloud specific version of JMap Cloud NG Core types and interfaces",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/public/core.d.ts CHANGED
@@ -799,6 +799,195 @@ declare namespace JMap {
799
799
  * Methods used to manage thematics for a layer.
800
800
  */
801
801
  namespace Thematic {
802
+ /**
803
+ * ***JMap.Layer.Thematic.addThematic***
804
+ *
805
+ * This method allows you to add a custom thematic on a JMap Cloud layer. This method only works with vector layers that have attributes.
806
+ *
807
+ * The {@link JLayerAddThematicParams} parameter that you must provide include those properties:
808
+ * * the JMap Cloud layer id
809
+ * * a {@link JLayerUserStyleRule} specification
810
+ * * an array of {@link JLayerSetStyleParams}
811
+ *
812
+ * The id of the thematic that will be created will be the same id than the {@link JLayerUserStyleRule} that you provided.
813
+ *
814
+ * All objects that you provide that require an id should have a unique uuid v4 id. Many programming languages let you generate such ids.
815
+ *
816
+ * @param params the params to provide for the thematic creation
817
+ *
818
+ * @example
819
+ * ```ts
820
+ * // this code will add a custom thematic on a project that have a layer named "Neighborhood" with a "nom_qr" attribute.
821
+ * const addPolygonThematic = () => {
822
+ * // find layer Neighborhood
823
+ * const layer = JMap.Layer.getLayers().find(
824
+ * l => l.elementType === "POLYGON" && l.attributes.length > 0 && l.name === "Neighborhood"
825
+ * )
826
+ * if (!layer) {
827
+ * return
828
+ * }
829
+ * const layerAttribute = layer.attributes.find(la => la.name === "nom_qr")
830
+ * if (!layerAttribute) {
831
+ * return
832
+ * }
833
+ * const layerId = layer.id
834
+ * const styles = []
835
+ * const condition1StyleId = "8ae59ba6-0b0b-4a5e-8f8e-5b138bd53767"
836
+ * const condition2StyleId = "eeeff29c-352f-4ba6-b354-7d7f7476f1fc"
837
+ * const condition3StyleId = "85014948-1071-4257-a2f7-dbf75182fbfb"
838
+ * const condition4StyleId = "f111e616-c4a6-497b-aeda-57af63c312b8"
839
+ * const condition1Names = ["Anjou", "Beaconsfield", "Beaurivage", "Bois-Francs"]
840
+ * const condition2Names = ["Étienne Desmarteaux", "Ville-Émard", "Tétreaultville", "Saint-Sulpice"]
841
+ * const condition3Names = ["Westmount", "Saint-Henri", "Pierrefonds-Est", "Sault-au-Récollet"]
842
+ * styles.push(
843
+ * {
844
+ * id: condition1StyleId,
845
+ * type: "POLYGON",
846
+ * borderColor: "#ff0000",
847
+ * borderThickness: 4,
848
+ * fillColor: "#00ff00"
849
+ * },
850
+ * {
851
+ * id: condition2StyleId,
852
+ * type: "POLYGON",
853
+ * borderColor: "#00ff00",
854
+ * borderThickness: 4,
855
+ * fillColor: "#0000ff"
856
+ * },
857
+ * {
858
+ * id: condition3StyleId,
859
+ * type: "POLYGON",
860
+ * borderColor: "#0000ff",
861
+ * borderThickness: 4,
862
+ * fillColor: "#ff0000"
863
+ * },
864
+ * {
865
+ * id: condition4StyleId,
866
+ * type: "POLYGON",
867
+ * borderColor: "#000000",
868
+ * borderThickness: 4,
869
+ * fillColor: "#ffffff"
870
+ * }
871
+ * )
872
+ * const styleRule = {
873
+ * active: true,
874
+ * id: "bc23f628-0fea-4e0c-8c23-d39c33ee0be2",
875
+ * layerId: String(layer.id),
876
+ * name: "Demographic repartition",
877
+ * conditions: [
878
+ * {
879
+ * id: "573bf973-b574-46b5-b852-1bd17aa94c19",
880
+ * name: "Less than 50 000 people",
881
+ * conditionExpressions: [
882
+ * {
883
+ * id: "d6b1d717-b936-4b86-9011-6ce28af35237",
884
+ * operator: "IN",
885
+ * attribute: layerAttribute,
886
+ * value: condition1Names
887
+ * }
888
+ * ],
889
+ * styleMapScales: [
890
+ * {
891
+ * id: "a9ba5215-0511-4aa3-a724-6f14f10ab315",
892
+ * maximumVisibleZoom: 23,
893
+ * minimumVisibleZoom: 0,
894
+ * styleId: condition1StyleId
895
+ * }
896
+ * ]
897
+ * },
898
+ * {
899
+ * id: "a35679fa-860d-47d4-9b1a-24006bdd78be",
900
+ * name: "Between 50 000 and 100 000",
901
+ * conditionExpressions: [
902
+ * {
903
+ * id: "66de5d3b-5041-43d2-86b2-2639326ee6f7",
904
+ * operator: "IN",
905
+ * attribute: layerAttribute,
906
+ * value: condition2Names
907
+ * }
908
+ * ],
909
+ * styleMapScales: [
910
+ * {
911
+ * id: "8fb646bb-afee-4a3c-9545-e9716049d307",
912
+ * maximumVisibleZoom: 23,
913
+ * minimumVisibleZoom: 0,
914
+ * styleId: condition2StyleId
915
+ * }
916
+ * ]
917
+ * },
918
+ * {
919
+ * id: "4bd67df3-1ea3-4f3e-ad4b-1baa75a5cd5f",
920
+ * name: "More than 100 000 people",
921
+ * conditionExpressions: [
922
+ * {
923
+ * id: "2ff931ee-fa32-43e6-a3b1-314a806734c0",
924
+ * operator: "IN",
925
+ * attribute: layerAttribute,
926
+ * value: condition3Names
927
+ * }
928
+ * ],
929
+ * styleMapScales: [
930
+ * {
931
+ * id: "d0ad4bf4-f6a7-46f1-866b-74f97a5e7775",
932
+ * maximumVisibleZoom: 23,
933
+ * minimumVisibleZoom: 0,
934
+ * styleId: condition3StyleId
935
+ * }
936
+ * ]
937
+ * },
938
+ * {
939
+ * id: "25a4e4da-fe14-470d-aac2-37cfa7e367e2",
940
+ * name: "Other",
941
+ * conditionExpressions: [
942
+ * {
943
+ * id: "45f491d3-3a7b-4975-9296-7ff6e8516a6d",
944
+ * operator: "NOT_IN",
945
+ * attribute: layerAttribute,
946
+ * value: condition1Names.concat(condition2Names).concat(condition3Names)
947
+ * }
948
+ * ],
949
+ * styleMapScales: [
950
+ * {
951
+ * id: "94331295-86b3-455c-8946-d45f79b8bd21",
952
+ * maximumVisibleZoom: 23,
953
+ * minimumVisibleZoom: 0,
954
+ * styleId: condition4StyleId
955
+ * }
956
+ * ]
957
+ * }
958
+ * ]
959
+ * }
960
+ * JMap.Layer.Thematic.addThematic({ layerId, styleRule, styles })
961
+ * console.log(`added thematic on layer "${layer.name}", ids = "${layer.id}","${styleRule.id}" `)
962
+ * }
963
+ *
964
+ * if (JMap.Map.isMapLoaded()) {
965
+ * addPolygonThematic()
966
+ * } else {
967
+ * JMap.Event.Map.on.mapLoad("my-custom-event-map-load-add-polygon-thematic", () => {
968
+ * JMap.Event.Map.remove("my-custom-event-map-load-add-polygon-thematic")
969
+ * addPolygonThematic()
970
+ * })
971
+ * }
972
+ * ```
973
+ */
974
+ function addThematic(params: JLayerAddThematicParams): Promise<void>
975
+
976
+ /**
977
+ * ***JMap.Layer.Thematic.deleteThematic***
978
+ *
979
+ * Deletes a thematic from JMap CLoud NG. The removal is client-side only and only for the current session.
980
+ *
981
+ * @example
982
+ * ```ts
983
+ * // delete a thematic
984
+ * JMap.Layer.Thematic.deleteThematic("d5185b58-4f7a-4689-bacd-656df2104da4","bc23f628-0fea-4e0c-8c23-d39c33ee0be2")
985
+ * ```
986
+ * @param layerId the JMap Cloud layer id
987
+ * @param thematicId the thematic id (Style Rule id)
988
+ */
989
+ function deleteThematic(layerId: JId, thematicId: JId): void
990
+
802
991
  /**
803
992
  * ***JMap.Layer.Thematic.getAllByLayerId***
804
993
  *
@@ -3135,7 +3324,16 @@ declare namespace JMap {
3135
3324
  * JMap.Map.setSelectionStyle("point-layer-id",{type:"POINT", symbolData:"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAACCElEQVR4XmNgwAH2vHQWjy9TOs/KxvQTyP2PC7NxMP0WlWSrBrKZELoJgI41Rtl6lgK/DG2FQIb8A2J7dDVQYM/IyPAfpFZYgv0akK+MrgADVM/SnS8oyva/eILW/1N/Pf+zsTN9Z8BhAUgtDz8LWB1IPQcX8xcGHGrBoH+LaRDIcJdQyf1A7gcGLEGCC4Mcktag+p+FlfE9kC8BNhAd+MRLP/ZLkgG54i0DPpdgB/a8Aqx/3SKkngLZfeiSDLMPWmgCFfyvnat7Csg9hy5PDJBV4f7Qt9H4PxMT40cglwtFMqNJvdPARvB/aLb8ZiB3NookkcDITvhs5XSd/6JS7DeBXGcUSZ846QvJNSr/FTV5dgK5GSiSRAI7X7GpASmy/0FmAbnNKJLaZvzfp+0x/8/KxngZyDVFkSQSWLiJeqob8v2fuNX0OZB7GEUSmKH+H/nqDkoRv4CYHUWSeMAOTEUwc0AZFAX8P/PfC5bsKAE4zQFL4MtYhAAs4+G0gAYYBYBtxoZxyeESh8mhmQ9RDPImA4nFBAyDgnfWAQv8FjBADLcHYeTwRHchsjguPXCToQAsAYtk9AhDNxxZHJceFNNhikFeBCkCYTTvYsUE9KAADBeiuxQd4xKHyaGZj+k6KmAEQE4BlGKklIgC7KGC6K4gB8NSFVYAdwmIjS6JA5CkhyTFUIBTDwBPxSZtxNLgXwAAAABJRU5ErkJggg=="})
3136
3325
  * ```
3137
3326
  */
3138
- function setSelectionStyle(layerId: JId, style: JLayerSetSelectionStyleParam): void
3327
+ function setSelectionStyle(layerId: JId, style: JLayerSetStyleParams): void
3328
+
3329
+ /**
3330
+ * ***JMap.Map.resetSelectionStyle***
3331
+ *
3332
+ * Sets back the selection style of a layer to its original value. Use this method when the selection style has been modified by {@link JMap.Map.setSelectionStyle} and the style modification is not needed anymore.
3333
+ *
3334
+ * @param layerId the JMap Cloud layer id
3335
+ */
3336
+ function resetSelectionStyle(layerId: JId): void
3139
3337
 
3140
3338
  /**
3141
3339
  * ***JMap.Map.setScaleControlVisibility***
@@ -8443,6 +8641,46 @@ declare namespace JMap {
8443
8641
  */
8444
8642
  function layerDeletion(listenerId: string, fn: (params: JLayerEventParams) => void): void
8445
8643
 
8644
+ /**
8645
+ * ***JMap.Event.Layer.on.thematicDeletion***
8646
+ *
8647
+ * This event is triggered when a thematic is deleted.
8648
+ *
8649
+ * @param listenerId Your listener id (must be unique for all layer events)
8650
+ * @param fn Your listener function
8651
+ * @example
8652
+ * ```ts
8653
+ * // Each time a thematic is deleted, will display a message in the console
8654
+ * JMap.Event.Layer.on.thematicDeletion(
8655
+ * "custom-thematic-deletion",
8656
+ * params => {
8657
+ * console.log(`Thematic id="${params.thematicId}" of layer id="${params.layerId}" has been deleted client-side`)
8658
+ * }
8659
+ * )
8660
+ * ```
8661
+ */
8662
+ function thematicDeletion(listenerId: string, fn: (params: JLayerThematicEventParams) => void): void
8663
+
8664
+ /**
8665
+ * ***JMap.Event.Layer.on.thematicAddition***
8666
+ *
8667
+ * This event is triggered when a custom thematic is added.
8668
+ *
8669
+ * @param listenerId Your listener id (must be unique for all layer events)
8670
+ * @param fn Your listener function
8671
+ * @example
8672
+ * ```ts
8673
+ * // Each time a custom thematic is added, will display a message in the console
8674
+ * JMap.Event.Layer.on.thematicAddition(
8675
+ * "custom-thematic-addition",
8676
+ * params => {
8677
+ * console.log(`Thematic has been added for layer id="${params.layerId}". Params: `, params)
8678
+ * }
8679
+ * )
8680
+ * ```
8681
+ */
8682
+ function thematicAddition(listenerId: string, fn: (params: JAddMapThematicEventParams) => void): void
8683
+
8446
8684
  /**
8447
8685
  * ***JMap.Event.Layer.on.initialSearchApplied***
8448
8686
  *
@@ -98,7 +98,9 @@ declare const enum JLAYER_STYLE_RULE_CONDITION_EXPRESSION_OPERATORS {
98
98
  GREATER_THAN = "GREATER_THAN",
99
99
  LOWER_THAN = "LOWER_THAN",
100
100
  GREATER_OR_EQUALS_TO = "GREATER_OR_EQUALS_TO",
101
- LOWER_OR_EQUALS_TO = "LOWER_OR_EQUALS_TO"
101
+ LOWER_OR_EQUALS_TO = "LOWER_OR_EQUALS_TO",
102
+ IN = "IN", // This operator does not yet exist in JMC
103
+ NOT_IN = "NOT_IN" // This operator does not yet exist in JMC
102
104
  }
103
105
 
104
106
  // ALL_LAYER_DYNAMIC_FILTER_OPERATORS in all-enum.ts
@@ -222,6 +224,16 @@ declare interface JLayerEventParams {
222
224
  layerId: JId
223
225
  }
224
226
 
227
+ declare interface JLayerThematicEventParams {
228
+ layerId: JId
229
+ thematicId: JId
230
+ }
231
+
232
+ declare interface JAddMapThematicEventParams {
233
+ layerId: JId
234
+ layerSpecifications: maplibregl.LayerSpecification[]
235
+ }
236
+
225
237
  declare interface JLayerInitialSearchEventParams extends JLayerEventParams {
226
238
  features: GeoJSON.Feature[]
227
239
  }
@@ -382,6 +394,7 @@ declare interface JLayerThematicClassification extends JLayerThematic {
382
394
  }
383
395
 
384
396
  declare interface JLayerThematicStyleRule extends JLayerThematic {
397
+ type: JLAYER_THEMATIC_TYPES.STYLE_RULE
385
398
  conditions: JLayerThematicCondition[]
386
399
  hiddenConditionIds: string[]
387
400
  }
@@ -439,6 +452,7 @@ declare interface JLayerStyleRule {
439
452
  declare interface JLayerStyleRuleCondition {
440
453
  id: string
441
454
  name: string
455
+ conditionExpressions: JLayerStyleRuleConditionExpression[]
442
456
  styleMapScales: JLayerStyleScaled[]
443
457
  }
444
458
 
@@ -454,8 +468,8 @@ declare interface JLayerStyleSample {
454
468
  imageSampleInBase64: string
455
469
  }
456
470
 
457
- // @TODO we probably don't need this interface anymore
458
471
  declare interface JLayerStyleRuleConditionExpression {
472
+ id: string
459
473
  operator: JLAYER_STYLE_RULE_CONDITION_EXPRESSION_OPERATORS
460
474
  value: any
461
475
  attribute: JLayerAttribute
@@ -520,11 +534,19 @@ declare interface JLayerTextStyle extends JLayerBaseStyle {
520
534
  italic: boolean
521
535
  }
522
536
 
523
- declare type JLayerSetSelectionStyleParam =
524
- | (Pick<JLayerLineStyle, "type"> & Partial<Pick<JLayerLineStyle, "lineColor" | "lineThickness">>)
537
+ declare type JLayerUserStyleRule = Omit<JLayerStyleRule, "defaultRule">
538
+
539
+ declare type JLayerAddThematicParams = {
540
+ layerId: JId
541
+ styleRule: JLayerUserStyleRule
542
+ styles: JLayerSetStyleParams[]
543
+ }
544
+
545
+ declare type JLayerSetStyleParams =
546
+ | (Pick<JLayerLineStyle, "type"> & Partial<Pick<JLayerLineStyle, "id" | "lineColor" | "lineThickness">>)
525
547
  | (Pick<JLayerPolygonStyle, "type"> &
526
- Partial<Pick<JLayerPolygonStyle, "fillColor" | "borderColor" | "borderThickness">>)
527
- | (Pick<JLayerPointStyle, "type"> & Partial<Pick<JLayerPointStyle, "symbolData">>)
548
+ Partial<Pick<JLayerPolygonStyle, "id" | "fillColor" | "borderColor" | "borderThickness">>)
549
+ | (Pick<JLayerPointStyle, "type"> & Partial<Pick<JLayerPointStyle, "id" | "symbolData">>)
528
550
 
529
551
  declare interface JLayerSetLayersVisibilityParams {
530
552
  layerId: JId