@planet/maps 11.0.0-dev.1741021734686 → 11.0.0-dev.1741027267187

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 +1 @@
1
- {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["render.js"],"names":[],"mappings":";;;;;AA4bA;;;GAGG;AACH,gCAHW,KAAK,CAAC,SAAS,aACf,GAAG,QAsBb;;;;;SAhVa,KAAI,OAAO,EAAE,GAAG,KAAK,GAAG;;;;cACxB,GAAG"}
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["render.js"],"names":[],"mappings":";;;;;AAidA;;;GAGG;AACH,gCAHW,KAAK,CAAC,SAAS,aACf,GAAG,QAsBb;;;;;SA7Va,KAAI,OAAO,EAAE,GAAG,KAAK,GAAG;;;;cACxB,GAAG"}
@@ -1,4 +1,5 @@
1
1
  import OLMap from 'ol/Map.js';
2
+ import {unByKey} from 'ol/Observable.js';
2
3
  import Overlay from 'ol/Overlay.js';
3
4
  import View from 'ol/View.js';
4
5
  import Control from 'ol/control/Control.js';
@@ -56,6 +57,8 @@ const knownTypes = {
56
57
  [SOURCE]: true,
57
58
  };
58
59
 
60
+ const customViewChangeEventType = 'custom-change';
61
+
59
62
  /**
60
63
  * @type {import('./update.js').Updater}
61
64
  */
@@ -72,10 +75,15 @@ export function updateInstanceFromProps(instance, type, oldProps, newProps) {
72
75
 
73
76
  if (listenerRegex.test(key)) {
74
77
  const listener = newProps[key];
75
- const eventType = key
78
+ let eventType = key
76
79
  .replace(listenerColonRegex, 'onChange:')
77
80
  .replace(listenerRegex, '$1')
78
81
  .toLowerCase();
82
+
83
+ // special handling for view change
84
+ if (instance instanceof View && eventType === 'change') {
85
+ eventType = customViewChangeEventType;
86
+ }
79
87
  instance.on(eventType, listener);
80
88
 
81
89
  const oldListener = oldProps[key];
@@ -161,7 +169,13 @@ function createTextInstance() {
161
169
  */
162
170
  function appendChildToContainer(map, child) {
163
171
  if (child instanceof View) {
172
+ const key = map.on('moveend', () => {
173
+ child.dispatchEvent(customViewChangeEventType);
174
+ });
164
175
  map.setView(child);
176
+ map.on('change:view', () => {
177
+ unByKey(key);
178
+ });
165
179
  return;
166
180
  }
167
181
  if (child instanceof Overlay) {
@@ -242,7 +256,8 @@ function commitUpdate(instance, type, oldProps, newProps) {
242
256
  */
243
257
  function removeChildFromContainer(map, child) {
244
258
  if (child instanceof View) {
245
- map.setView(child);
259
+ // @ts-ignore (remove when https://github.com/openlayers/openlayers/pull/16691 is released)
260
+ map.setView(null);
246
261
  return;
247
262
  }
248
263
  if (child instanceof Overlay) {
@@ -308,7 +323,13 @@ function insertInCollection(collection, child, beforeChild) {
308
323
  */
309
324
  function insertInContainerBefore(map, child, beforeChild) {
310
325
  if (child instanceof View) {
326
+ const key = map.on('moveend', () => {
327
+ child.dispatchEvent(customViewChangeEventType);
328
+ });
311
329
  map.setView(child);
330
+ map.on('change:view', () => {
331
+ unByKey(key);
332
+ });
312
333
  return;
313
334
  }
314
335
  let collection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planet/maps",
3
- "version": "11.0.0-dev.1741021734686",
3
+ "version": "11.0.0-dev.1741027267187",
4
4
  "description": "Declarative mapping components for React",
5
5
  "type": "module",
6
6
  "repository": {