maplibre-preview 1.2.7 → 1.3.7

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: 435a1fa5a333e26e727a36278e76340f0d3dd7599dc981c1b8bf756d541a208e
4
- data.tar.gz: 0f6a6667ca6065865e9cd14642a4b63850cb271e3a416fec598a8e15e4c6ae9d
3
+ metadata.gz: 1e8b7e6d3882215e2027f65d54d9e06c580674d09e11c7099a8713de14979100
4
+ data.tar.gz: 74975af297edce53fe68f87621be8104936f17969afbed60a241065f46e6c702
5
5
  SHA512:
6
- metadata.gz: 7fec8cd86f4f8b66fd4400ec2a3fcc8983a1a9042f9754d12b22f8f353e55790c4ff6a395d1ff70f304cc502391ba2eb3a7754ea353f3ebe1bdffc2632341eec
7
- data.tar.gz: dd9b8db806f1a62b90841b38c56b024897bc95c448899e2cf9b02426a05090b12ef0f207671f9c6c95b85bb159797979ea8591605f204bda06dab417559dcc8d
6
+ metadata.gz: 6735dbe8cce4882f933922a6f4cf9a5ce6de961e128e21f671f21f2b38067f0fb2aef5507e404c8aba7fab8fb6e8db9b3925edd618a1c399d37893b4465f458d
7
+ data.tar.gz: f667f936f515cbd8390abd5dadbcebfdf61a29572feed3496361a08d941f32a6d0acf6f75949c9bff537f56213d60172baebd0537f1687eee63ed2de96e8c45f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.3.7] - 2025-10-29
4
+
5
+ ### Added
6
+ - **Antialias toggle control** - button to enable/disable antialias with localStorage persistence and page reload
7
+ - **Style-based initial view** - support for `center` and `zoom` properties from style JSON according to MapLibre Style Spec
8
+
9
+ ### Changed
10
+ - **Default map center** - updated to `[96.63, 64.81]`
11
+
3
12
  ## [1.2.7] - 2025-10-20
4
13
 
5
14
  ### Fixed
data/README.md CHANGED
@@ -118,8 +118,8 @@ This starts a complete web server with:
118
118
 
119
119
  The gem uses fixed configurations for optimal compatibility:
120
120
 
121
- - **Map Center**: `[35.15, 47.41]`
122
- - **Initial Zoom**: `2`
121
+ - **Map Center**: `[96.63, 64.81]` (default, can be overridden by style's `center` property)
122
+ - **Initial Zoom**: `2` (default, can be overridden by style's `zoom` property)
123
123
  - **Basemap**: OpenStreetMap tiles with 0.8 opacity
124
124
  - **Library Versions**: MapLibre GL JS 5.7.3, MapLibre Contour 0.1.0, D3.js 7
125
125
 
data/docs/README_RU.md CHANGED
@@ -118,8 +118,8 @@ MapLibrePreview::App.run!
118
118
 
119
119
  Gem использует фиксированные настройки:
120
120
 
121
- - **Центр карты**: `[35.15, 47.41]`
122
- - **Начальный зум**: `2`
121
+ - **Центр карты**: `[96.63, 64.81]` (по умолчанию, можно переопределить свойством `center` в стиле)
122
+ - **Начальный зум**: `2` (по умолчанию, можно переопределить свойством `zoom` в стиле)
123
123
  - **Базовая карта**: Тайлы OpenStreetMap с прозрачностью 0.8
124
124
  - **Версии библиотек**: MapLibre GL JS 5.7.3, MapLibre Contour 0.1.0, D3.js 7
125
125
 
@@ -1,3 +1,3 @@
1
1
  module MapLibrePreview
2
- VERSION = '1.2.7'
2
+ VERSION = '1.3.7'
3
3
  end
@@ -16,6 +16,7 @@ ruby:
16
16
  button.mode-button id="mode-layers" onclick="switchMode(this, 'layers')" Layers
17
17
  button.control-button onclick="toggleHoverMode()" id="hover-mode-btn" Hover Mode
18
18
  button.control-button onclick="toggleProfileMode()" id="profile-mode-btn" style="display: none;" Elevation Profile
19
+ button.control-button onclick="toggleAntialias()" id="antialias-btn" Antialias
19
20
 
20
21
  #filters-panel.control-panel.active
21
22
  .control-panel-header
@@ -76,6 +77,7 @@ javascript:
76
77
  let hoverMode = 'click';
77
78
  let layerStates = {};
78
79
  let map = null;
80
+ let antialiasEnabled = localStorage.getItem('antialiasEnabled') !== 'false';
79
81
  let styleLoaded = false, resourcesLoaded = 0, totalResources = 0;
80
82
  let tilesLoaded = 0, tilesTotal = 0;
81
83
  let currentStyle = null;
@@ -175,15 +177,23 @@ javascript:
175
177
  }
176
178
  };
177
179
 
178
- const createMap = (container, style) => new maplibregl.Map({
179
- container,
180
- style,
181
- center: [35.15, 47.41],
182
- zoom: 2,
183
- attributionControl: false,
184
- validateStyle: false,
185
- antialias: true
186
- });
180
+ const createMap = (container, style) => {
181
+ const defaultCenter = [96.637778, 64.811389];
182
+ const defaultZoom = 2;
183
+
184
+ const center = Array.isArray(style?.center) && style.center.length === 2 ? style.center : defaultCenter;
185
+ const zoom = typeof style?.zoom === 'number' ? style.zoom : defaultZoom;
186
+
187
+ return new maplibregl.Map({
188
+ container,
189
+ style,
190
+ center,
191
+ zoom,
192
+ attributionControl: false,
193
+ validateStyle: false,
194
+ antialias: antialiasEnabled
195
+ });
196
+ };
187
197
 
188
198
  const addBasemapToStyle = (originalStyle) => {
189
199
  const modifiedStyle = JSON.parse(JSON.stringify(originalStyle));
@@ -389,7 +399,7 @@ javascript:
389
399
 
390
400
  const setupPerformanceMonitoring = () => {
391
401
  [startPerformanceMonitoring, () => requestAnimationFrame(countFrame),
392
- updateHoverModeButton, updateBasemapButton].forEach(fn => fn());
402
+ updateHoverModeButton, updateBasemapButton, updateAntialiasButton].forEach(fn => fn());
393
403
  };
394
404
 
395
405
  const toggleBasemap = () => {
@@ -831,6 +841,20 @@ javascript:
831
841
  requestAnimationFrame(countFrame);
832
842
  };
833
843
 
844
+ const toggleAntialias = () => {
845
+ antialiasEnabled = !antialiasEnabled;
846
+ localStorage.setItem('antialiasEnabled', antialiasEnabled.toString());
847
+ window.location.reload();
848
+ };
849
+
850
+ const updateAntialiasButton = () => {
851
+ const btn = document.getElementById('antialias-btn');
852
+ if (!btn) return;
853
+
854
+ btn.textContent = `Antialias: ${antialiasEnabled ? 'ON' : 'OFF'}`;
855
+ btn.className = `control-button ${antialiasEnabled ? 'active' : 'inactive'}`;
856
+ };
857
+
834
858
  window.switchMode = switchMode;
835
859
  window.toggleBasemap = toggleBasemap;
836
860
  window.toggleHoverMode = toggleHoverMode;
@@ -838,6 +862,7 @@ javascript:
838
862
  window.toggleAllLayers = toggleAllLayers;
839
863
  window.togglePerformancePanel = togglePerformancePanel;
840
864
  window.toggleProfileMode = toggleProfileMode;
865
+ window.toggleAntialias = toggleAntialias;
841
866
  window.hideProfile = hideProfile;
842
867
 
843
868
  initializeMap();
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.2.7
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Ludov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-10-20 00:00:00.000000000 Z
11
+ date: 2025-10-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack