@sapui5/sap.ui.vbm 1.138.0 → 1.140.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sapui5/sap.ui.vbm",
3
- "version": "1.138.0",
3
+ "version": "1.140.0",
4
4
  "description": "SAPUI5 Library sap.ui.vbm",
5
5
  "homepage": "https://sap.github.io/ui5-tooling/pages/SAPUI5/",
6
6
  "author": "SAP SE (https://www.sap.com)",
@@ -3,7 +3,7 @@
3
3
  <name>sap.ui.vbm</name>
4
4
  <vendor>SAP SE</vendor>
5
5
  <copyright>SAP UI development toolkit for HTML5 (SAPUI5) (c) Copyright 2009-2012 SAP AG. All rights reserved</copyright>
6
- <version>1.138.0</version>
6
+ <version>1.140.0</version>
7
7
 
8
8
  <documentation>SAP UI library: sap.ui.vbm</documentation>
9
9
 
@@ -24,7 +24,7 @@ sap.ui.define([
24
24
  * @param {string} [sId] id for the new control, generated automatically if no id is given
25
25
  * @param {object} [mSettings] initial settings for the new object
26
26
  * @author SAP SE
27
- * @version 1.138.0
27
+ * @version 1.140.0
28
28
  * @extends sap.ui.core.Element
29
29
  * @constructor
30
30
  * @public
@@ -47,7 +47,7 @@ sap.ui.define([
47
47
  * @param {string} [sId] id for the new control, generated automatically if no id is given
48
48
  * @param {object} [mSettings] initial settings for the new object
49
49
  * @author SAP SE
50
- * @version 1.138.0
50
+ * @version 1.140.0
51
51
  * @extends sap.ui.core.Element
52
52
  * @constructor
53
53
  * @public
@@ -300,7 +300,7 @@ sap.ui.define([
300
300
  xhr.open("GET", sPathGeoJSON, false); // set 'false' to make it synchronous
301
301
  xhr.send();
302
302
 
303
- if (xhr.status === 200) {
303
+ if (xhr.status === 200 && !!xhr.responseText) {
304
304
  oData = JSON.parse(xhr.responseText);
305
305
  } else {
306
306
  // Handle error
@@ -23,7 +23,7 @@ sap.ui.define([
23
23
  *
24
24
  * @public
25
25
  * @author SAP SE
26
- * @version 1.138.0
26
+ * @version 1.140.0
27
27
  * @extends sap.ui.core.Control
28
28
  * @alias sap.ui.vbm.Viewport
29
29
  */
@@ -22,7 +22,7 @@ sap.ui.define([
22
22
  *
23
23
  * @private
24
24
  * @author SAP SE
25
- * @version 1.138.0
25
+ * @version 1.140.0
26
26
  * @alias sap.ui.vbm.adapter3d.ColladaBounds
27
27
  */
28
28
  var ColladaBounds = BaseObject.extend("sap.ui.vbm.adapter3d.ColladaBounds", /** @lends sap.ui.vbm.adapter3d.ColladaBounds.prototype */ {
@@ -83,7 +83,7 @@ sap.ui.define([
83
83
  *
84
84
  * @private
85
85
  * @author SAP SE
86
- * @version 1.138.0
86
+ * @version 1.140.0
87
87
  * @alias sap.ui.vbm.adapter3d.DragDropHandler
88
88
  */
89
89
  var DragDropHandler = BaseObject.extend("sap.ui.vbm.adapter3d.DragDropHandler", /** @lends sap.ui.vbm.adapter3d.DragDropHandler.prototype */ {
@@ -29,7 +29,7 @@ sap.ui.define([
29
29
  *
30
30
  * @private
31
31
  * @author SAP SE
32
- * @version 1.138.0
32
+ * @version 1.140.0
33
33
  * @alias sap.ui.vbm.adapter3d.ModelHandler
34
34
  */
35
35
  var ModelHandler = BaseObject.extend("sap.ui.vbm.adapter3d.ModelHandler", /** @lends sap.ui.vbm.adapter3d.ModelHandler.prototype */ {
@@ -377,7 +377,7 @@ sap.ui.define([
377
377
  *
378
378
  * @private
379
379
  * @author SAP SE
380
- * @version 1.138.0
380
+ * @version 1.140.0
381
381
  * @alias sap.ui.vbm.adapter3d.ObjectFactory
382
382
  */
383
383
  var ObjectFactory = BaseObject.extend("sap.ui.vbm.adapter3d.ObjectFactory", /** @lends sap.ui.vbm.adapter3d.ObjectFactory.prototype */ {});
@@ -32,7 +32,7 @@ sap.ui.define([
32
32
  *
33
33
  * @private
34
34
  * @author SAP SE
35
- * @version 1.138.0
35
+ * @version 1.140.0
36
36
  * @alias sap.ui.vbm.adapter3d.PolygonHandler
37
37
  */
38
38
  var PolygonHandler = BaseObject.extend("sap.ui.vbm.adapter3d.PolygonHandler", /** @lends sap.ui.vbm.adapter3d.PolygonHandler.prototype */ {
@@ -39,7 +39,7 @@ sap.ui.define([
39
39
  *
40
40
  * @private
41
41
  * @author SAP SE
42
- * @version 1.138.0
42
+ * @version 1.140.0
43
43
  * @alias sap.ui.vbm.adapter3d.RectangleTracker
44
44
  */
45
45
  var RectangleTracker = BaseObject.extend("sap.ui.vbm.adapter3d.RectangleTracker", /** @lends sap.ui.vbm.adapter3d.RectangleTracker.prototype */ {
@@ -496,7 +496,7 @@ sap.ui.define([
496
496
 
497
497
  RectangleTracker.prototype.searchChildInFrustum = function (frustum, object) {
498
498
  var count = 0;
499
- if (object._sapInstance != undefined && !object.geomtry) {
499
+ if (object._sapInstance != undefined && ((object._sapInstance["VB:c"] == 'true' ) || !(object._sapInstance["VB:c"]) )) {
500
500
  var box1 = new THREE.BoxHelper(object, 0x000000);
501
501
  var vertices = box1.geometry.attributes.position.array;
502
502
  for (var i = 0, l = vertices.length; i < l; i += 3) {
@@ -47,7 +47,7 @@ sap.ui.define([
47
47
  *
48
48
  * @private
49
49
  * @author SAP SE
50
- * @version 1.138.0
50
+ * @version 1.140.0
51
51
  * @alias sap.ui.vbm.adapter3d.SceneBuilder
52
52
  */
53
53
  var SceneBuilder = BaseObject.extend("sap.ui.vbm.adapter3d.SceneBuilder", /** @lends sap.ui.vbm.adapter3d.SceneBuilder.prototype */ {
@@ -56,7 +56,7 @@ sap.ui.define([
56
56
  *
57
57
  * @private
58
58
  * @author SAP SE
59
- * @version 1.138.0
59
+ * @version 1.140.0
60
60
  * @alias sap.ui.vbm.adapter3d.VBIJSONParser
61
61
  */
62
62
  var VBIJSONParser = BaseObject.extend("sap.ui.vbm.adapter3d.VBIJSONParser", /** @lends sap.ui.vbm.adapter3d.VBIJSONParser.prototype */ {
@@ -20,7 +20,7 @@ sap.ui.define([
20
20
  * @namespace
21
21
  * @alias sap.ui.vbm
22
22
  * @author SAP SE
23
- * @version 1.138.0
23
+ * @version 1.140.0
24
24
  * @public
25
25
  */
26
26
 
@@ -46,7 +46,7 @@ sap.ui.define([
46
46
  "sap.ui.vbm.ClusterBase", "sap.ui.vbm.ClusterTree", "sap.ui.vbm.ClusterGrid", "sap.ui.vbm.ClusterDistance", "sap.ui.vbm.Heatmap",
47
47
  "sap.ui.vbm.HeatPoint", "sap.ui.vbm.ClusterContainer", "sap.ui.vbm.Adapter", "sap.ui.vbm.Adapter3D"
48
48
  ],
49
- version: "1.138.0"
49
+ version: "1.140.0"
50
50
  });
51
51
 
52
52
  sap.ui.loader.config({
@@ -39,7 +39,7 @@ sap.ui.define([
39
39
  let fixedBounds;
40
40
  var containerID;
41
41
  let previousCenter = null;
42
- let previousZoom = null;
42
+ let previousZoom = null;
43
43
 
44
44
 
45
45
 
@@ -59,11 +59,11 @@ sap.ui.define([
59
59
  }
60
60
 
61
61
  VBI.MapRenderer.renderMap = () => {
62
-
62
+
63
63
  if (this.map) {
64
64
  previousCenter = this.map.getCenter();
65
65
  previousZoom = this.map.getZoom();
66
- this.map.remove();
66
+ this.map.remove();
67
67
  }
68
68
 
69
69
  let geoJSON = VBI.VBITransformer.getTransformedJSON();
@@ -76,6 +76,7 @@ sap.ui.define([
76
76
  document.head.appendChild(styleSheet);
77
77
 
78
78
  const map = VectorUtils.createMap(geoJSON, map_container);
79
+ map.doubleClickZoom.disable();
79
80
 
80
81
  if (previousCenter && previousZoom !== null) {
81
82
  map.jumpTo({
@@ -104,13 +105,13 @@ sap.ui.define([
104
105
  map.on('load', () => {
105
106
 
106
107
  map.getCanvas().style.cursor = 'default';
107
- map.on('mouseup', function () {
108
- map.getCanvas().style.cursor = 'default';
109
- });
110
- map.getCanvas().addEventListener('mousemove', function () {
111
- map.getCanvas().style.cursor = 'default';
112
- });
113
-
108
+ map.on('mouseup', function () {
109
+ map.getCanvas().style.cursor = 'default';
110
+ });
111
+ map.getCanvas().addEventListener('mousemove', function () {
112
+ map.getCanvas().style.cursor = 'default';
113
+ });
114
+
114
115
  if (VBI.mapFlags.isLegendExists) {
115
116
  // Legend control
116
117
  VBI.VBITransformer._createLegend(map_container);
@@ -163,8 +164,12 @@ sap.ui.define([
163
164
  if (marker.geometry.type === 'Point') {
164
165
  // create a DOM element for the marker (parent div)
165
166
  const el = VectorUtils.createSpotElement(marker);
167
+ if (marker.properties.Label) {
168
+ const child_e1 = VectorUtils.createMarkerLabel(marker.properties.Label, marker.properties.LabelBGColor);
169
+ el.appendChild(child_e1);
170
+ }
166
171
  if (marker.properties.Icon) {
167
- const iconColor = marker.properties.contentColor? marker.properties.contentColor : "#000000";
172
+ const iconColor = marker.properties.contentColor ? marker.properties.contentColor : "#000000";
168
173
  // Create child element for the SAP icon (icon overlay)
169
174
  const child_el = VectorUtils.createIconElement(marker.properties.Icon, iconColor);
170
175
  child_el.id = '__mapspot' + spotid++;
@@ -396,9 +401,69 @@ sap.ui.define([
396
401
  if (that.Apressed || that.Rpressed) {
397
402
  el.style.cursor = 'crosshair';
398
403
  } else {
399
- const tooltipContent = marker.properties.ToolTip.replace(/\n/g, '<br>');
400
- const tooltip = `<div style="background-color: white; color: black;">${tooltipContent}</div>`;
401
- popup.setLngLat(marker.geometry.coordinates).setHTML(tooltip).addTo(map);
404
+ function renderTooltip(marker, popup, map) {
405
+ if (!document.getElementById('custom-maplibre-tooltip-style')) {
406
+ const style = document.createElement('style');
407
+ style.id = 'custom-maplibre-tooltip-style';
408
+ style.innerHTML = `
409
+ .maplibregl-popup {
410
+ background: transparent !important;
411
+ box-shadow: none !important;
412
+ padding: 0 !important;
413
+ width: auto;
414
+ }
415
+ .maplibregl-popup-content {
416
+ background: transparent !important;
417
+ padding: 0 !important;
418
+ box-shadow: none !important;
419
+ border-radius: 0 !important;
420
+ width: auto;
421
+ }
422
+ `;
423
+ document.head.appendChild(style);
424
+ }
425
+
426
+ const isDarkTheme = window.matchMedia &&
427
+ window.matchMedia('(prefers-color-scheme: dark)').matches;
428
+
429
+ const outerBorderColor = 'none';
430
+ const innerBgColor = isDarkTheme ? '#545555' : '#f0f0f0';
431
+ const textColor = isDarkTheme ? 'white' : 'f0f0f0';
432
+
433
+ const tooltipContent = marker.properties.ToolTip.replace(/\n/g, '<br>');
434
+
435
+ const tooltip = `
436
+
437
+ <div style="
438
+ background-color: ${innerBgColor};
439
+ color: ${textColor};
440
+ padding: 8px;
441
+ border-radius: 6px;
442
+ max-height: 180px;
443
+ display: inline-block;
444
+ font-family: Arial;
445
+ font-size: 0.875rem;
446
+ width: auto;
447
+ white-space: nowrap;
448
+ border: 2px solid ${outerBorderColor};
449
+ ">
450
+ ${tooltipContent}
451
+ </div>`;
452
+
453
+ popup.setLngLat(marker.geometry.coordinates)
454
+ .setHTML(tooltip)
455
+ .addTo(map);
456
+ }
457
+
458
+ // 2. Initial render
459
+ renderTooltip(marker, popup, map);
460
+
461
+ // 3. Re-render tooltip on system theme change
462
+ window.matchMedia('(prefers-color-scheme: dark)')
463
+ .addEventListener('change', () => {
464
+ popup.remove();
465
+ renderTooltip(marker, popup, map);
466
+ });
402
467
  }
403
468
  }
404
469
 
@@ -417,6 +482,10 @@ sap.ui.define([
417
482
  PayloadGenerator.objectClick('Spot', event, marker, clickCoordinates);
418
483
  };
419
484
 
485
+ el.addEventListener('dblclick', (e) => {
486
+ triggerPayloadSpot(e, 'DOUBLE_CLICK');
487
+ });
488
+
420
489
  el.addEventListener('click', (e) => {
421
490
  //Trigger payload
422
491
  triggerPayloadSpot(e, 'DETAIL_REQUEST');
@@ -444,6 +513,16 @@ sap.ui.define([
444
513
  predefinedMarkers.push(markerCoordinates);
445
514
  }
446
515
  } else if (marker.geometry.type == "LineString") {
516
+
517
+ const colorStr = marker.properties.LineColor;
518
+ let textColor = '#000000'; // Default color
519
+
520
+ if (colorStr) {
521
+ const [r, g, b, a] = VectorUtils.parseRGBAString(colorStr);
522
+ textColor = VectorUtils.getContrastTextColor(r, g, b);
523
+ marker.properties.labelHaloColor = `rgba(${r}, ${g}, ${b}, ${a})`;
524
+ }
525
+ marker.properties.textColor = textColor;
447
526
  const coords = marker.geometry.coordinates;
448
527
  const startCoord = coords[0]; // First coordinate
449
528
  const endCoord = coords[coords.length - 1]; // Last coordinate
@@ -499,10 +578,10 @@ sap.ui.define([
499
578
  }
500
579
 
501
580
  });
502
- if(VBI.mapFlags.automations){
581
+ if (VBI.mapFlags.automations) {
503
582
  let automations = new SAPAutomationManager(map, maplibregl.LngLatBounds);
504
583
  automations.load(VBI.mapFlags.automations);
505
- }
584
+ }
506
585
  map.addLayer({
507
586
  'id': 'geojson-source-point',
508
587
  'type': 'circle',
@@ -542,6 +621,30 @@ sap.ui.define([
542
621
  },
543
622
  'filter': ['==', '$type', 'LineString']
544
623
  });
624
+
625
+ map.addLayer({
626
+ id: 'line-labels',
627
+ type: 'symbol',
628
+ source: 'geojson-source',
629
+ layout: {
630
+ 'symbol-placement': 'line-center',
631
+ 'text-field': ['get', 'Label'],
632
+ 'text-font': ['Open Sans Regular', 'Arial Unicode MS Regular'],
633
+ 'text-size': 14,
634
+ 'text-rotation-alignment': 'map',
635
+ 'text-keep-upright': true
636
+ },
637
+ paint: {
638
+ 'text-color': ['get', 'lineLabelTextColor'],
639
+ 'text-halo-color': ['get', 'labelHaloColor'],
640
+ 'text-halo-width': 4,
641
+ 'text-halo-blur': 0.8,
642
+ 'text-opacity': ['get', 'opacity']
643
+ },
644
+
645
+ filter: ['all', ['==', ['get', 'ShowLabel'], true]]
646
+ });
647
+
545
648
  // Create a new FeatureCollection for the points
546
649
  const pointGeoJSON = {
547
650
  'type': 'FeatureCollection',
@@ -590,18 +693,62 @@ sap.ui.define([
590
693
  }
591
694
  });
592
695
  });
593
-
594
696
  });
697
+
595
698
  // Change mouse cursor when hovering over the line
596
699
  map.on('mouseenter', 'geojson-source-route', function (event) {
597
700
  if (!that.Apressed && !that.Rpressed) {
598
701
  map.getCanvas().style.cursor = 'pointer';
599
702
  }
703
+ if (!document.getElementById('custom-maplibre-tooltip-style')) {
704
+ const style = document.createElement('style');
705
+ style.id = 'custom-maplibre-tooltip-style';
706
+ style.innerHTML = `
707
+ .maplibregl-popup {
708
+ background: transparent !important;
709
+ box-shadow: none !important;
710
+ padding: 0 !important;
711
+ width: auto;
712
+ }
713
+ .maplibregl-popup-content {
714
+ background: transparent !important;
715
+ padding: 0 !important;
716
+ box-shadow: none !important;
717
+ border-radius: 0 !important;
718
+ width: auto;
719
+ } `;
720
+ document.head.appendChild(style);
721
+ }
722
+
723
+ const isDarkTheme = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;
724
+
725
+ const outerBorderColor = 'none';
726
+ const innerBgColor = isDarkTheme ? '#545555' : '#f0f0f0';
727
+ const textColor = isDarkTheme ? 'white' : 'f0f0f0';
728
+
600
729
  const coordinates = event.lngLat;
601
- const description = event.features[0].properties.ToolTip;
730
+ const description = event.features[0].properties.ToolTip || "";
731
+
602
732
  const tooltipContent = description.replace(/\n/g, '<br>');
603
- const tooltip = `<div style="background-color: white; color: black;">${tooltipContent}</div>`;
733
+
734
+ const tooltip = ` <div style="
735
+ background-color: ${innerBgColor};
736
+ color: ${textColor};
737
+ padding: 8px;
738
+ border-radius: 6px;
739
+ max-height: 180px;
740
+ display: inline-block;
741
+ font-family: Arial;
742
+ font-size: 0.875rem;
743
+ width: auto;
744
+ white-space: nowrap;
745
+ border: 2px solid ${outerBorderColor};
746
+ ">
747
+ ${tooltipContent}
748
+ </div> `;
749
+
604
750
  popupLink.setLngLat(coordinates).setHTML(tooltip).addTo(map);
751
+
605
752
  });
606
753
 
607
754
  // Revert mouse cursor back when not hovering
@@ -611,14 +758,12 @@ sap.ui.define([
611
758
  }
612
759
  popupLink.remove();
613
760
  });
761
+
614
762
  map.on('click', 'geojson-source-route', function (e) {
615
763
  //Trigger payload
616
764
  triggerPayloadRoute(e, 'DETAIL_REQUEST');
617
765
  });
618
- // map.getContainer().addEventListener('contextmenu', 'geojson-source-route', function (e) {
619
- // //Trigger payload
620
- // triggerPayloadRoute(e, 'DETAIL_REQUEST');
621
- // });
766
+
622
767
  function triggerPayloadRoute(e, event) {
623
768
  // Get the mouse coordinates within the map container
624
769
  const offsetX = e.offsetX;
@@ -636,7 +781,7 @@ sap.ui.define([
636
781
  function triggerPayloaddnd() {
637
782
  PayloadGenerator.objectDrop(action, dropItems);
638
783
  }
639
-
784
+
640
785
  map.on('mousedown', 'geojson-source-route', (e) => {
641
786
  dragInstance = map.queryRenderedFeatures(e.point, {
642
787
  layers: ['geojson-source-route']
@@ -667,7 +812,7 @@ sap.ui.define([
667
812
  map.on('mousemove', onMove);
668
813
  map.on('mouseup', onUp);
669
814
 
670
-
815
+
671
816
  if (!that.Apressed && !that.Rpressed) {
672
817
  map.getCanvas().style.cursor = 'pointer';
673
818
  }
@@ -722,10 +867,10 @@ sap.ui.define([
722
867
  }
723
868
 
724
869
  // Reset cursor and remove event listeners
725
- map.getCanvas().style.cursor = 'default';
870
+ map.getCanvas().style.cursor = 'default';
726
871
  setTimeout(() => {
727
- map.getCanvas().style.cursor = 'default';
728
- }, 100);
872
+ map.getCanvas().style.cursor = 'default';
873
+ }, 100);
729
874
  map.off('mousemove', onMove);
730
875
  map.off('mouseup', onUp);
731
876
  lineDrag = false;
@@ -752,12 +897,12 @@ sap.ui.define([
752
897
  map.getCanvas().style.cursor = validDrop ? 'copy' : 'not-allowed';
753
898
  }
754
899
  else {
755
-
900
+
756
901
  map.getCanvas().style.cursor = 'default';
757
902
  }
758
903
  }
759
904
  }
760
-
905
+
761
906
  mapCanvas.oncontextmenu = (e) => {
762
907
  e.preventDefault();
763
908
  // Get the mouse coordinates within the map container
@@ -12,7 +12,7 @@ sap.ui.define([
12
12
  *
13
13
  * @private
14
14
  * @author SAP SE
15
- * @version 1.138.0
15
+ * @version 1.140.0
16
16
  * @alias sap.ui.vbm.vector.PayloadGenerator
17
17
  */
18
18
  var adapter = {};
@@ -12,7 +12,7 @@ sap.ui.define([
12
12
  *
13
13
  * @private
14
14
  * @author SAP SE
15
- * @version 1.138.0
15
+ * @version 1.140.0
16
16
  * @alias sap.ui.vbm.vector.RectangularSelection
17
17
  */
18
18
 
@@ -320,7 +320,6 @@ sap.ui.define([
320
320
  let routeProperties = {
321
321
  "GeoPosition": currRoute.A ? currRoute.A : "",
322
322
  "ToolTip": currRoute.B ? currRoute.B : "",
323
- "Label": currRoute.L ? currRoute.L : "",
324
323
  "LabelBGColor": currRoute.LC ? currRoute.LC : "",
325
324
  "LabelAlignment": currRoute.LA ? currRoute.LA : "",
326
325
  "Color": currRoute.C ? VectorUtils.argbToRgba(currRoute.C) : "",
@@ -337,10 +336,30 @@ sap.ui.define([
337
336
  "DotWidth": currRoute.DW ? currRoute.DW : "",
338
337
  "DotColor": currRoute.DC ? currRoute.DC : "",
339
338
  "LineDash": currRoute.LD ? currRoute.LD : "",
339
+ "LineColor": currRoute.F ? currRoute.F : "",
340
340
  "DirectionIndicator": currRoute.DI ? currRoute.DI : "",
341
341
  "DragData": currRoute.DD ? currRoute.DD : "",
342
342
  "type": "{00100000-2012-0004-B001-C46BD7336A1A}"
343
343
  };
344
+ let labeledRoutes = new Set();
345
+ if (currRoute.L) {
346
+ routeProperties["Label"] = currRoute.L;
347
+ // ✅ Only label the first route with this Label
348
+ if (!labeledRoutes.has(currRoute.L)) {
349
+ routeProperties["ShowLabel"] = true;
350
+ labeledRoutes.add(currRoute.L);
351
+ }
352
+ }
353
+ const colorStr = currRoute.F;
354
+ routeProperties["lineLabelTextColor"] = '#000000'; // Default color
355
+
356
+ if (colorStr) {
357
+ const [r, g, b, a] = VectorUtils.parseRGBAString(colorStr);
358
+ routeProperties["lineLabelTextColor"] = VectorUtils.getContrastTextColor(r, g, b);
359
+ const { hexColor, opacity } = VectorUtils.rgbaToHexAndOpacity(colorStr);
360
+ routeProperties["labelHaloColor"] = hexColor;
361
+ routeProperties["opacity"] = opacity;
362
+ }
344
363
 
345
364
  //itearate through the route points and add the coordinates to the GeoJSON
346
365
  let coord_array = currRoute.H.split(";");
@@ -360,7 +379,7 @@ sap.ui.define([
360
379
  "properties": routeProperties,
361
380
  "geometry": geometry,
362
381
  // "id" : currRoute['VB:ix'],
363
- "id": route_id++,
382
+ "id": route_id++
364
383
  };
365
384
  let indexNum = featureCollection.findIndex(item => item.properties.Key === route_data.properties.Key)
366
385
  if (indexNum !== -1) {
@@ -378,7 +397,6 @@ sap.ui.define([
378
397
  let routeProperties = {
379
398
  "GeoPosition": currRoute.A ? currRoute.A : "",
380
399
  "ToolTip": currRoute.B ? currRoute.B : "",
381
- "Label": currRoute.L ? currRoute.L : "",
382
400
  "LabelBGColor": currRoute.LC ? currRoute.LC : "",
383
401
  "LabelAlignment": currRoute.LA ? currRoute.LA : "",
384
402
  "Color": currRoute.C ? VectorUtils.argbToRgba(currRoute.C) : "",
@@ -395,11 +413,32 @@ sap.ui.define([
395
413
  "DotWidth": currRoute.DW ? currRoute.DW : "",
396
414
  "DotColor": currRoute.DC ? currRoute.DC : "",
397
415
  "LineDash": currRoute.LD ? currRoute.LD : "",
416
+ "LineColor": currRoute.F ? currRoute.F : "",
398
417
  "DirectionIndicator": currRoute.DI ? currRoute.DI : "",
399
418
  "DragData": currRoute.DD ? currRoute.DD : "",
400
419
  "type": "{00100000-2012-0004-B001-C46BD7336A1A}"
420
+
401
421
 
402
422
  };
423
+ let labeledRoutes = new Set();
424
+ if (currRoute.L) {
425
+ routeProperties["Label"] = currRoute.L;
426
+ // ✅ Only label the first route with this Label
427
+ if (!labeledRoutes.has(currRoute.L)) {
428
+ routeProperties["ShowLabel"] = true;
429
+ labeledRoutes.add(currRoute.L);
430
+ }
431
+ }
432
+ const colorStr = currRoute.F;
433
+ routeProperties["lineLabelTextColor"] = '#000000'; // Default color
434
+
435
+ if (colorStr) {
436
+ const [r, g, b, a] = VectorUtils.parseRGBAString(colorStr);
437
+ routeProperties["lineLabelTextColor"] = VectorUtils.getContrastTextColor(r, g, b);
438
+ const { hexColor, opacity } = VectorUtils.rgbaToHexAndOpacity(colorStr);
439
+ routeProperties["labelHaloColor"] = hexColor;
440
+ routeProperties["opacity"] = opacity;
441
+ }
403
442
 
404
443
  //itearate through the route points and add the coordinates to the GeoJSON
405
444
  let coord_array = currRoute.H.split(";");
@@ -37,7 +37,7 @@ sap.ui.define([
37
37
  VectorUtils.createSpotElement = (marker) => {
38
38
  // create a DOM element for the marker (parent div)
39
39
  const el = document.createElement('div');
40
-
40
+
41
41
  // Set background image for the marker
42
42
  var base64decoded = "data:image/png;base64," + marker.properties.base64;
43
43
  el.style.backgroundImage = `url(${base64decoded})`;
@@ -65,10 +65,10 @@ sap.ui.define([
65
65
  return child_el;
66
66
  }
67
67
  //Function to set the canvas id
68
- VectorUtils._setcanvasid = () => {
69
- var mapCanvas = '__mapcanvas';
68
+ VectorUtils._setcanvasid = () => {
69
+ var mapCanvas = '__mapcanvas';
70
70
  return mapCanvas;
71
- }
71
+ }
72
72
 
73
73
  VectorUtils.createDropdownMenu = (menuData) => {
74
74
  const dropdown = document.createElement('div');
@@ -232,6 +232,72 @@ sap.ui.define([
232
232
 
233
233
  return windowContainer;
234
234
  };
235
+
236
+ VectorUtils.createMarkerLabel = (label, labelcolor) => {
237
+ var r, g, b, a;
238
+ const obj = document.createElement('div');
239
+ obj.className = 'marker-label';
240
+ obj.textContent = label;
241
+ obj.style.color = labelcolor;
242
+ obj.style.position = 'absolute';
243
+ obj.style.top = '100%';
244
+ if (!labelcolor) {
245
+ [r, g, b, a] = [211, 211, 211, 1];
246
+ } else {
247
+ [r, g, b, a] = VectorUtils.parseRGBAString(labelcolor);
248
+ }
249
+ obj.style.backgroundColor = `rgba(${r}, ${g}, ${b}, ${a})`;
250
+ obj.style.border = `2px solid rgba(${r}, ${g}, ${b}, ${a})`;
251
+ const textColor = VectorUtils.getContrastTextColor(r, g, b);
252
+ obj.style.color = textColor;
253
+ obj.style.fontFamily = 'Arial, sans-serif';
254
+ obj.style.fontSize = '14px';
255
+ return obj;
256
+ }
257
+ VectorUtils.rgbaToHexAndOpacity = (rgbaString) => {
258
+ const rgbaRegex = /rgba?\s*\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d*\.?\d+)\s*\)/i;
259
+ const match = rgbaString.match(rgbaRegex);
260
+
261
+ if (!match) {
262
+ throw new Error("Invalid RGBA format");
263
+ }
264
+
265
+ const r = parseInt(match[1], 10);
266
+ const g = parseInt(match[2], 10);
267
+ const b = parseInt(match[3], 10);
268
+ const a = parseFloat(match[4]);
269
+
270
+ const toHex = (value) => value.toString(16).padStart(2, '0');
271
+
272
+ const hex = `#${toHex(r)}${toHex(g)}${toHex(b)}`;
273
+
274
+ return {
275
+ hexColor: hex,
276
+ opacity: a
277
+ };
278
+ }
279
+
280
+
281
+ VectorUtils.parseRGBAString = (rgbaStr) => {
282
+ const match = rgbaStr.match(/rgba?\s*\(\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)\s*\)/i);
283
+
284
+ if (!match) return null;
285
+
286
+ const r = parseInt(match[1]);
287
+ const g = parseInt(match[2]);
288
+ const b = parseInt(match[3]);
289
+ const a = parseInt(match[4]) / 255;
290
+
291
+ return [r, g, b, parseFloat(a.toFixed(3))];
292
+ }
293
+
294
+ VectorUtils.getContrastTextColor = (r, g, b) => {
295
+ if (r === 0 && g === 0 && b === 0) {
296
+ return '#000000';
297
+ }
298
+ const brightness = 0.299 * r + 0.587 * g + 0.114 * b;
299
+ return brightness < 128 ? '#FFFFFF' : '#000000';
300
+ }
235
301
  VectorUtils.createSubCaption = (item) => {
236
302
  const obj = document.createElement('div');
237
303
  obj.setAttribute("role", sap.ui.core.AccessibleRole.Secondary);