maplibre-preview 1.1.3 → 1.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f628d2aac593618e8775a688086609010893a9ca6191dcade5ba61a9254f0517
4
- data.tar.gz: 2de4ff80fe3ba39d4b80d1340b49484a5fa35eee47200db2abff869fa8bd0233
3
+ metadata.gz: 880bdf4635bf0ab9f3164d52eaa89b30af2158b92d7f18a66ae3826eb6b038d9
4
+ data.tar.gz: f83cd22d094dd39d8be2e5eee0e0b8b41e15f7f4456e4d78e21f94016265d957
5
5
  SHA512:
6
- metadata.gz: a8a63f3fd6948997cc2f789afac439cc25d434281a44c10912b0ad662084fd22cbcaa7013b5284e3b1700c7c3f6f80dee806fbe82d7972e9be0bae840b0fa1fc
7
- data.tar.gz: cf4a12c6f6176b60f360bd9d753050e9ac07b728ea981c8985aa217ace3828a5fa81dc962320fef7f3cde3e7a9d9c905baad6b2d17eb84e20b8416312d96e334
6
+ metadata.gz: 28419d7377ec6f75213f617d5fbe33d35ba85392373e0db9eb8b430bb474d636095b4373b3f51ccd3a99d4057ee5a1b8af098700d3540c55d58a2a12987ab00e
7
+ data.tar.gz: 17418dbe1c8e87bab566c75102435e3cde668ec59345a65eda810b55c844b7bb02c0a85d4aabfd8d57e10c23693344e2a7096ce3fea64abd4e40eb73b0b7152e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.4] - 2025-10-03
4
+
5
+ ### Fixed
6
+ - **Terrain elevation correction** for accurate height display in tooltips and profiles
7
+ - **Centralized exaggeration compensation** with `getRealTerrainElevation` function
8
+
3
9
  ## [1.1.0] - 2025-10-01
4
10
 
5
11
  ### Refactored
@@ -1,3 +1,3 @@
1
1
  module MapLibrePreview
2
- VERSION = '1.1.3'
2
+ VERSION = '1.1.4'
3
3
  end
@@ -85,6 +85,14 @@ javascript:
85
85
 
86
86
  const toDomId = (prefix, id) => `${prefix}-${String(id).replace(/[^a-zA-Z0-9_-]/g, '_')}`;
87
87
 
88
+ const getRealTerrainElevation = (lngLat) => {
89
+ const elevation = map.queryTerrainElevation(lngLat);
90
+ if (elevation == null) return null;
91
+
92
+ const exaggeration = currentStyle?.terrain?.exaggeration || 1.0;
93
+ return elevation / exaggeration;
94
+ };
95
+
88
96
  const showLoading = () => document.getElementById('loading-indicator').style.display = 'block';
89
97
  const hideLoading = () => document.getElementById('loading-indicator').style.display = 'none';
90
98
 
@@ -322,11 +330,11 @@ javascript:
322
330
  features.length > 0 && console.log('Clicked feature:', features[0]);
323
331
 
324
332
  if (hoverMode === 'click' && currentStyle?.terrain) {
325
- const elevation = map.queryTerrainElevation([e.lngLat.lng, e.lngLat.lat]);
326
- if (elevation != null) {
333
+ const realElevation = getRealTerrainElevation([e.lngLat.lng, e.lngLat.lat]);
334
+ if (realElevation != null) {
327
335
  elevationTooltip && elevationTooltip.style.display === 'block'
328
336
  ? hideElevationTooltip()
329
- : showElevationTooltip(e.originalEvent, elevation);
337
+ : showElevationTooltip(e.originalEvent, realElevation);
330
338
  }
331
339
  }
332
340
  });
@@ -352,8 +360,10 @@ javascript:
352
360
  hideElevationTooltip();
353
361
 
354
362
  if (currentStyle?.terrain) {
355
- const elevation = map.queryTerrainElevation([e.lngLat.lng, e.lngLat.lat]);
356
- elevation != null && showElevationTooltip(e.originalEvent, elevation);
363
+ const realElevation = getRealTerrainElevation([e.lngLat.lng, e.lngLat.lat]);
364
+ if (realElevation != null) {
365
+ showElevationTooltip(e.originalEvent, realElevation);
366
+ }
357
367
  }
358
368
 
359
369
  profileMode && profilePoints.length === 1 && updateTemporaryLine(e.lngLat);
@@ -489,10 +499,10 @@ javascript:
489
499
  const t = i / numPoints;
490
500
  const lng = start.lng + (end.lng - start.lng) * t;
491
501
  const lat = start.lat + (end.lat - start.lat) * t;
492
- const elevation = map.queryTerrainElevation([lng, lat]);
502
+ const realElevation = getRealTerrainElevation([lng, lat]);
493
503
  const distance = calculateDistance([start.lng, start.lat], [lng, lat]);
494
504
 
495
- return {distance, elevation: elevation || 0, coordinates: [lng, lat]};
505
+ return {distance, elevation: realElevation, coordinates: [lng, lat]};
496
506
  });
497
507
  };
498
508
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maplibre-preview
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Ludov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-10-02 00:00:00.000000000 Z
11
+ date: 2025-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack