maplibre-preview 1.9.1 → 1.10.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4804849d0779e4a60b497a251fa9ad350615671a328d446b383c991b6fda041a
4
- data.tar.gz: 3349b9e73f70f57d3dd83d3c3586c44a5180ec9cc5d93d5932e4b246f82a1003
3
+ metadata.gz: d77238823bad1c9b83f993dab458e964ffd16fb6015f3506bbd62d86b690e131
4
+ data.tar.gz: 70b749547c4d2115fc20a0bde6c43ceb3303ddf1b22a1fc4a570e1ae12117552
5
5
  SHA512:
6
- metadata.gz: c8e02627ba370010afa83daf7e0d2770d6d0ea3dc919761b976789cbcc9f60f88735196c1546c50467e2eca8b468fe0212160b6dd20b88c0982b5787a4313a92
7
- data.tar.gz: 823cfad1bf6bb3d5f2602d4a592654189b40fb7d594430409bf3d8610827e04069867901a5044abf9408049b29698b2bcd7fa72ff6f36e3e8be8db83e48a6a19
6
+ metadata.gz: 0e64e1a5d7e2334ad705a18ccca590143d33c1c562094a0fb216aa2502b4b2666736633404e08d1233f5d260d978c7e8006a4f96e02122303199a066f2a8b20e
7
+ data.tar.gz: 51dbf7525797540e8de7ba77400d4d062bfb8cf2a6bbb1248b7c8e8b5027341825afe2654bc76bac64f5af6f6cc9e36b0d43b339534f6f7749b779a36c9867bd
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.10.0] - 2026-05-20
4
+
5
+ ### Added
6
+ - **Host coordinate selection** - emit `maplibre-preview:coordinate-selected` with `lat` and `lon` on map clicks for embedded host applications
7
+
8
+ ### Changed
9
+ - **Embedded preview route** - pass configured preview options into the `/maplibre_preview` template route
10
+
3
11
  ## [1.9.1] - 2026-05-15
4
12
 
5
13
  ### Security
@@ -1,3 +1,3 @@
1
1
  module MapLibrePreview
2
- VERSION = '1.9.1'
2
+ VERSION = '1.10.0'
3
3
  end
@@ -809,6 +809,17 @@ javascript:
809
809
  popup.setLngLat(e.lngLat).setDOMContent(createPopupContent(tooltips)).addTo(map);
810
810
  };
811
811
 
812
+ const emitCoordinateSelection = (lngLat) => {
813
+ const payload = {
814
+ type: 'maplibre-preview:coordinate-selected',
815
+ lat: lngLat.lat,
816
+ lon: lngLat.lng
817
+ };
818
+
819
+ window.dispatchEvent(new CustomEvent(payload.type, {detail: payload}));
820
+ window.parent !== window && window.parent.postMessage(payload, window.location.origin);
821
+ };
822
+
812
823
  const initializeMap = async () => {
813
824
  showLoading();
814
825
  const emptyStyle = {version: 8, sources: {}, layers: []};
@@ -918,6 +929,8 @@ javascript:
918
929
  const popup = new maplibregl.Popup({closeButton: false, closeOnClick: false});
919
930
 
920
931
  map.on('click', function (e) {
932
+ emitCoordinateSelection(e.lngLat);
933
+
921
934
  if (profileMode) {
922
935
  handleProfileClick(e);
923
936
  return;
@@ -33,7 +33,7 @@ module MapLibrePreview
33
33
  app.set :maplibre_preview_options, {}
34
34
 
35
35
  app.get '/maplibre_preview' do
36
- slim :maplibre_map, layout: :maplibre_layout
36
+ slim :maplibre_map, layout: :maplibre_layout, locals: { options: settings.maplibre_preview_options }
37
37
  end
38
38
  end
39
39
  end
@@ -15,6 +15,7 @@ RSpec.describe MapLibrePreview do
15
15
  expect(last_response.body).to include('maplibre-contour')
16
16
  expect(last_response.body).to include('d3')
17
17
  expect(last_response.body).to include('overlay_layout')
18
+ expect(last_response.body).to include('maplibre-preview:coordinate-selected')
18
19
  end
19
20
 
20
21
  it 'renders map cache toggle wiring' do
@@ -91,6 +92,14 @@ RSpec.describe MapLibrePreview do
91
92
  expect(last_response.body).not_to include('setHTML(tooltips')
92
93
  end
93
94
 
95
+ it 'emits selected coordinates for host applications' do
96
+ get '/'
97
+ expect(last_response).to be_ok
98
+
99
+ expect(last_response.body).to include('emitCoordinateSelection(e.lngLat)')
100
+ expect(last_response.body).to include('window.parent.postMessage(payload, window.location.origin)')
101
+ end
102
+
94
103
  it 'serves all required JavaScript modules' do
95
104
  %w[/js/overlay_layout.js /js/filters.js /js/contour.js /js/tilegrid.js /js/temporal_picker.js /vendor/maplibre-gl/maplibre-gl.js /vendor/maplibre-contour/index.min.js /vendor/d3/d3.v7.min.js].each do |js_file|
96
105
  get js_file
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.9.1
4
+ version: 1.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Ludov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-05-15 00:00:00.000000000 Z
11
+ date: 2026-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack