@sapui5/sap.ui.vbm 1.131.0 → 1.133.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.
@@ -1,12 +1,12 @@
1
1
 
2
2
  sap.ui.define([
3
3
  "sap/ui/base/Object",
4
- ], function (BaseObject) {
4
+ "sap/ui/core/Lib"
5
+ ], function (BaseObject, Lib) {
5
6
  'use strict';
6
7
 
7
8
  const VectorUtils = BaseObject.extend("sap.ui.vbm.vector.VectorUtils", /** @lends sap.ui.vbm.vector.VectorUtils.prototype */ {
8
9
  });
9
-
10
10
  VectorUtils.createMap = (geoJSON, map_container) => {
11
11
 
12
12
  return new maplibregl.Map({
@@ -134,10 +134,334 @@ sap.ui.define([
134
134
  };
135
135
 
136
136
  // Method to format the coordinates
137
- VectorUtils.formatCoordinates = function (coords) {
137
+ VectorUtils.formatCoordinates = (coords) => {
138
138
  return `${coords.lng};${coords.lat};0.0`;
139
139
  };
140
140
 
141
+ // Method to create detail window
142
+ VectorUtils.createDetailWindowContainer = (details) => {
143
+
144
+ // create the detail frame................................................//
145
+ const windowContainer = document.createElement('div');
146
+ windowContainer.setAttribute("role", sap.ui.core.AccessibleRole.Secondary);
147
+ windowContainer.style.left = "0px";
148
+ windowContainer.style.top = "0px";
149
+
150
+ // ask whether phone or not
151
+ var bPhone = VBI.m_bIsPhone;
152
+ // add the size of the decorators.........................................//
153
+ if (!bPhone) {
154
+ var paddingDesktop = 16;
155
+ var spacingDesktop = 16;
156
+ var headerFontSize = 16;
157
+ paddingDesktop = VBI.Utilities.RemToPixel(1);
158
+ spacingDesktop = VBI.Utilities.RemToPixel(1);
159
+ headerFontSize = VBI.Utilities.RemToPixel(1);
160
+ if (details.width) {
161
+ windowContainer.style.width = parseInt(details.width) + 2 * paddingDesktop + "px";
162
+ }
163
+ if (details.height) {
164
+ windowContainer.style.minHeight = parseInt(details.height) + headerFontSize + 4 + spacingDesktop + 2 * paddingDesktop + "px";
165
+ }
166
+ } else {
167
+ var paddingPhone = 12;
168
+ var spacingPhone = 6;
169
+ var headerFontSizePhone = 14;
170
+ paddingPhone = VBI.Utilities.RemToPixel(0.750);
171
+ spacingPhone = VBI.Utilities.RemToPixel(0.375);
172
+ headerFontSizePhone = VBI.Utilities.RemToPixel(0.875);
173
+
174
+ if (details.height) {
175
+ windowContainer.style.minHeight = details.height + headerFontSizePhone + 4 + spacingPhone + 2 * paddingPhone + "px";
176
+ }
177
+ }
178
+
179
+ windowContainer.className = "vbi-detail vbi-detail-border";
180
+
181
+
182
+ // create the header,.....................................................//
183
+ const header = document.createElement('div');
184
+ header.setAttribute("role", sap.ui.core.AccessibleRole.Heading);
185
+ header.className = "vbi-detail-header";
186
+ windowContainer.appendChild(header);
187
+
188
+ // create the title......................................................//
189
+ const title = document.createElement('div');
190
+ title.setAttribute("role", sap.ui.core.AccessibleRole.Heading);
191
+ title.className = "vbi-detail-title";
192
+ title.innerText = details.caption;
193
+ header.appendChild(title);
194
+ if (details.caption && details.caption !== '') {
195
+ this._upperElementExists = true;
196
+ }
197
+
198
+ // create the close.......................................................//
199
+ var close = document.createElement('div');
200
+ close.setAttribute("role", sap.ui.core.AccessibleRole.Button);
201
+ // ensures the library is loaded
202
+ Lib.load({ name: "sap.ui.vbm.i18n" });
203
+ // ResourceBundle can be retrieved
204
+ var oResourceBundle = Lib.getResourceBundleFor("sap.ui.vbm.i18n")
205
+ close.title = oResourceBundle.getText("WINDOW_CLOSE");
206
+ close.setAttribute("aria-label", oResourceBundle.getText("WINDOW_CLOSE"));
207
+ close.className = "vbi-detail-closebutton vbi-detail-closebutton-" + (VBI.m_bIsMobile ? "tablet" : "desktop");
208
+ close.addEventListener('click', function () { VBI.MapRenderer.closePopup() });
209
+ header.appendChild(close);
210
+
211
+ // set arrows.............................................................//
212
+ const newB = document.createElement('b');
213
+ newB.setAttribute("role", sap.ui.core.AccessibleRole.Presentation);
214
+ newB.className = "vbi-detail-arrow vbi-detail-left vbi-detail-border-arrow";
215
+ if (!bPhone) {
216
+ windowContainer.appendChild(newB);
217
+ }
218
+
219
+ const newBArrow = document.createElement('b');
220
+ newBArrow.setAttribute("role", sap.ui.core.AccessibleRole.Presentation);
221
+ newBArrow.className = "vbi-detail-arrow vbi-detail-left";
222
+ if (!bPhone) {
223
+ windowContainer.appendChild(newBArrow);
224
+ }
225
+
226
+ return windowContainer;
227
+ };
228
+ VectorUtils.createSubCaption = (item) => {
229
+ const obj = document.createElement('div');
230
+ obj.setAttribute("role", sap.ui.core.AccessibleRole.Secondary);
231
+ obj.className = "vbi-2d-caption vbi-2d-common";
232
+ obj.innerText = item.text;
233
+ obj.style.left = item.left + "px";
234
+ if (this._upperElementExists) {
235
+ obj.style.marginTop = item.top + "px";
236
+ } else {
237
+ obj.style.top = item.top + "px";
238
+ }
239
+ obj.style.marginLeft = "15px";
240
+ obj.style.width = (item.right - item.left).toString() + "px";
241
+ obj.style.height = (item.bottom - item.top).toString() + "px";
242
+ obj.style.textAlign = VBI.Utilities.Align[item.align];
243
+ if (item.level === "3") {
244
+ obj.classList.add('sapUiVbmDetailWindowCaption3');
245
+ }
246
+ this._upperElementExists = true;
247
+ return obj;
248
+ };
249
+ VectorUtils.createLabel = (item, data) => {
250
+ const obj = document.createElement('div');
251
+ obj.setAttribute("role", sap.ui.core.AccessibleRole.Description);
252
+ obj.style.left = item.left + "px";
253
+ if (this._upperElementExists) {
254
+ obj.style.marginTop = item.top + "px";
255
+ } else {
256
+ obj.style.top = item.top + "px";
257
+ }
258
+ obj.style.marginLeft = "15px";
259
+ obj.style.width = (item.right - item.left).toString() + "px";
260
+ obj.style.height = (item.bottom - item.top).toString() + "px";
261
+ obj.style.textAlign = VBI.Utilities.Align[item.align];
262
+ obj.style.title = item.tooltip;
263
+ obj.className = "vbi-2d-label vbi-2d-common";
264
+ obj.innerText = getTextFromData(item["text.bind"], data); // Function to bind text from data
265
+ this._upperElementExists = true;
266
+ return obj;
267
+ };
268
+
269
+ VectorUtils.createLink = (item) => {
270
+ const obj = document.createElement('a');
271
+ obj.setAttribute("role", sap.ui.core.AccessibleRole.Link);
272
+ obj.style.left = item.left + "px";
273
+ if (this._upperElementExists) {
274
+ obj.style.marginTop = item.top + "px";
275
+ } else {
276
+ obj.style.top = item.top + "px";
277
+ }
278
+ obj.style.marginLeft = "15px";
279
+ obj.style.width = (item.right - item.left).toString() + "px";
280
+ obj.style.height = (item.bottom - item.top).toString() + "px";
281
+ obj.style.textAlign = VBI.Utilities.Align[item.align];
282
+ obj.innerText = item.text;
283
+ obj.className = "vbi-2d-link vbi-2d-common";
284
+ obj.href = item.href ? item.href : "javascrip" + "t:void(0)"; // separated to fool ESLint
285
+ obj.title = item.tooltip;
286
+ this._upperElementExists = true;
287
+ return obj;
288
+ };
289
+
290
+ VectorUtils.createImage = (item, defaultbase64, resourceMap) => {
291
+ const obj = document.createElement('img');
292
+ if (item.image && item.image !== "") {
293
+ obj.setAttribute("role", sap.ui.core.AccessibleRole.Img);
294
+ obj.style.left = item.left + "px";
295
+ if (this._upperElementExists) {
296
+ obj.style.marginTop = item.top + "px";
297
+ } else {
298
+ obj.style.top = item.top + "px";
299
+ }
300
+ obj.style.marginLeft = "15px";
301
+ obj.style.width = (item.right - item.left).toString() + "px";
302
+ obj.style.height = (item.bottom - item.top).toString() + "px";
303
+ obj.style.textAlign = VBI.Utilities.Align[item.align];
304
+ obj.className = "vbi-2d-image vbi-2d-common";
305
+ obj.title = item.tooltip;
306
+ if (item.image === "@01@") { //Default pin
307
+ obj.src = getImageUrl(defaultbase64);
308
+ } else {
309
+ obj.src = getImageUrl(resourceMap.get(item.image)); // Function to handle image URLs
310
+ }
311
+
312
+ }
313
+ this._upperElementExists = true;
314
+ return obj;
315
+ };
316
+
317
+ VectorUtils.createButton = (item, actions) => {
318
+ const obj = document.createElement('button');
319
+ obj.style.left = item.left + "px";
320
+ if (this._upperElementExists) {
321
+ obj.style.marginTop = item.top + "px";
322
+ } else {
323
+ obj.style.top = item.top + "px";
324
+ }
325
+ obj.style.marginLeft = "15px";
326
+ obj.style.width = (item.right - item.left).toString() + "px";
327
+ obj.style.height = (item.bottom - item.top).toString() + "px";
328
+ obj.style.textAlign = VBI.Utilities.Align[item.align];
329
+ obj.className = "vbi-2d-button vbi-2d-common";
330
+ obj.title = item.tooltip;
331
+ obj.innerText = item.text;
332
+ obj.onclick = () => handleAction(item.id, actions); // Bind click event
333
+ this._upperElementExists = true;
334
+ return obj;
335
+ };
336
+
337
+ VectorUtils.argbToRgba = (argbString) => {
338
+
339
+ // Remove "ARGB(" and ")" from the string and split the values by commas
340
+ let argbValues = argbString.replace('ARGB(', '').replace(')', '').split(',');
341
+
342
+ // Parse the values as integers
343
+ let alpha = parseInt(argbValues[0].trim(), 10);
344
+ let red = parseInt(argbValues[1].trim(), 10);
345
+ let green = parseInt(argbValues[2].trim(), 10);
346
+ let blue = parseInt(argbValues[3].trim(), 10);
347
+
348
+ // Convert alpha from 0-255 range to 0-1 range
349
+ let alphaDecimal = alpha / 255;
350
+
351
+ // Return the RGBA string
352
+ return `rgba(${red}, ${green}, ${blue}, ${alphaDecimal.toFixed(2)})`;
353
+ };
354
+
355
+ VectorUtils.getArrowHead = (callback) => {
356
+ const svgArrow = `
357
+ <svg fill="currentColor" width="60px" height="60px" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
358
+ <g data-name="Layer 2">
359
+ <g data-name="arrow-right">
360
+ <rect width="24" height="24" transform="rotate(180 12 12)" opacity="0"/>
361
+ <path d="M10.46 18a2.23 2.23 0 0 1-.91-.2 1.76 1.76 0 0 1-1.05-1.59V7.79A1.76 1.76 0 0 1 9.55 6.2a2.1 2.1 0 0 1 2.21.26l5.1 4.21a1.7 1.7 0 0 1 0 2.66l-5.1 4.21a2.06 2.06 0 0 1-1.3.46z"/>
362
+ </g>
363
+ </g>
364
+ </svg>`;
365
+
366
+ const base64 = `data:image/svg+xml;base64,${btoa(svgArrow)}`;
367
+ const img = new Image();
368
+ img.src = base64;
369
+ img.onload = () => callback(img);
370
+ };
371
+
372
+ VectorUtils.normalizeAngle = (angle) => {
373
+ return (angle + 360) % 360;
374
+ };
375
+
376
+ // Function to calculate the bearing between two points
377
+ VectorUtils.calculateBearing = (start, end) => {
378
+ const lat1 = toRadians(start[1]);
379
+ const lat2 = toRadians(end[1]);
380
+ const dLon = toRadians(end[0] - start[0]);
381
+
382
+ const x = Math.cos(lat2) * Math.sin(dLon);
383
+ const y = Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) * Math.cos(dLon);
384
+
385
+ const initialBearing = Math.atan2(x, y);
386
+ return VectorUtils.normalizeAngle(toDegrees(initialBearing)); // Normalize to 0-360 degrees
387
+ };
388
+
389
+
390
+ // Helper functions
391
+
392
+ function toRadians(degrees) {
393
+ return degrees * Math.PI / 180;
394
+ }
395
+
396
+ function toDegrees(radians) {
397
+ return radians * 180 / Math.PI;
398
+ }
399
+ function getTextFromData(binding, data) {
400
+ const keys = binding.split('.').slice(1); // Split binding path
401
+ let value = data[keys[2]].T; // Start with the data object
402
+ return value ? value : ''; // Return the text value
403
+ }
404
+
405
+ function getImageUrl(imageReference) {
406
+ // Resolve image URLs
407
+ return "data:text/plain;base64," + imageReference
408
+ }
409
+
410
+ function handleAction(actionId, actions) {
411
+ const action = actions.find(action => action.id === actionId);
412
+ if (action) {
413
+ console.log("Performing action:", action.Action.name);
414
+ // Implement the action logic here, e.g., triggering an event or action
415
+ }
416
+ }
417
+ function GetEventVPCoords(event, map_container) {
418
+ // returns the relative pixel coordinates to the viewport of the.......//
419
+ // provided event......................................................//
420
+ if (!event) {
421
+ return [
422
+ 0, 0
423
+ ];
424
+ }
425
+
426
+ var rect = GetInternalDivClientRect(map_container);
427
+ if (VBI.m_bIsRtl) {
428
+ return [
429
+ rect.right - event.clientX, event.clientY - rect.top
430
+ ];
431
+
432
+ } else {
433
+ return [
434
+ event.clientX - rect.left, event.clientY - rect.top
435
+ ];
436
+ }
437
+ };
438
+
439
+
440
+
441
+ VectorUtils.GetEventVPCoordsObj = (event, map_container) => {
442
+ // returns the view port coordinates in an object......................//
443
+ var pos = GetEventVPCoords(event, map_container);
444
+ return {
445
+ x: pos[0].toString(),
446
+ y: pos[1].toString()
447
+ };
448
+ };
449
+
450
+ VectorUtils.GetEventDropObjWithScene = (event) => {
451
+ return {
452
+ // strSource: scene.m_DragInfo.strScene + "|" + scene.m_DragInfo.strID + "|" + scene.m_DragInfo.strInstance,
453
+ // scene: scene.m_ID
454
+ };
455
+
456
+ };
457
+ function GetInternalDivClientRect(map_container) {
458
+ // Assuming your map is initialized on an element with the ID 'map'
459
+ const mapContainer = document.getElementById(map_container);
460
+
461
+ // Get the bounding rectangle
462
+ const rect = mapContainer.getBoundingClientRect();
463
+ return rect;
464
+ };
141
465
 
142
466
  return VectorUtils;
143
467
 
@@ -714,7 +714,17 @@ sap.ui.define([
714
714
  top: 0 !important;
715
715
  width: 100% !important;
716
716
  z-index: 99999;
717
- }`;
717
+ }
718
+
719
+ .boxdraw {
720
+ background: rgba(56, 135, 190, 0.1);
721
+ border: 2px solid #3887be;
722
+ position: absolute;
723
+ top: 0;
724
+ left: 0;
725
+ width: 0;
726
+ height: 0;
727
+ }`;
718
728
 
719
729
  return styles;
720
730
  }