@planet/maps 7.1.0 → 8.0.0-dev.1666713300824
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.
- package/LICENSE +202 -0
- package/config.js +32 -0
- package/lib/Map.js +70 -0
- package/lib/Overlay.js +24 -0
- package/lib/View.js +24 -0
- package/lib/control/Attribution.js +24 -0
- package/lib/control/Control.js +24 -0
- package/lib/control/FullScreen.js +24 -0
- package/lib/control/MousePosition.js +24 -0
- package/lib/control/OverviewMap.js +24 -0
- package/lib/control/Rotate.js +24 -0
- package/lib/control/ScaleLine.js +24 -0
- package/lib/control/Zoom.js +24 -0
- package/lib/control/ZoomSlider.js +24 -0
- package/lib/control/ZoomToExtent.js +24 -0
- package/lib/interaction/DoubleClickZoom.js +24 -0
- package/lib/interaction/DragAndDrop.js +24 -0
- package/lib/interaction/DragBox.js +24 -0
- package/lib/interaction/DragPan.js +24 -0
- package/lib/interaction/DragRotate.js +24 -0
- package/lib/interaction/DragRotateAndZoom.js +28 -0
- package/lib/interaction/DragZoom.js +24 -0
- package/lib/interaction/Draw.js +24 -0
- package/lib/interaction/Extent.js +24 -0
- package/lib/interaction/Interaction.js +24 -0
- package/lib/interaction/KeyboardPan.js +24 -0
- package/lib/interaction/KeyboardZoom.js +24 -0
- package/lib/interaction/Link.js +24 -0
- package/lib/interaction/Modify.js +24 -0
- package/lib/interaction/MouseWheelZoom.js +24 -0
- package/lib/interaction/PinchRotate.js +24 -0
- package/lib/interaction/PinchZoom.js +24 -0
- package/lib/interaction/Pointer.js +24 -0
- package/lib/interaction/Property.js +24 -0
- package/lib/interaction/Select.js +24 -0
- package/lib/interaction/Snap.js +24 -0
- package/lib/interaction/Translate.js +24 -0
- package/lib/layer/Base.js +29 -0
- package/lib/layer/BaseImage.js +29 -0
- package/lib/layer/BaseTile.js +29 -0
- package/lib/layer/BaseVector.js +29 -0
- package/lib/layer/Graticule.js +29 -0
- package/lib/layer/Group.js +29 -0
- package/lib/layer/Heatmap.js +29 -0
- package/lib/layer/Image.js +29 -0
- package/lib/layer/Layer.js +29 -0
- package/lib/layer/MapboxVector.js +29 -0
- package/lib/layer/Tile.js +29 -0
- package/lib/layer/Vector.js +29 -0
- package/lib/layer/VectorImage.js +29 -0
- package/lib/layer/VectorTile.js +29 -0
- package/lib/layer/WebGLPoints.js +29 -0
- package/lib/layer/WebGLTile.js +29 -0
- package/lib/source/BingMaps.js +24 -0
- package/lib/source/CartoDB.js +24 -0
- package/lib/source/Cluster.js +24 -0
- package/lib/source/DataTile.js +24 -0
- package/lib/source/GeoTIFF.js +24 -0
- package/lib/source/IIIF.js +24 -0
- package/lib/source/Image.js +24 -0
- package/lib/source/ImageArcGISRest.js +24 -0
- package/lib/source/ImageCanvas.js +24 -0
- package/lib/source/ImageMapGuide.js +24 -0
- package/lib/source/ImageStatic.js +24 -0
- package/lib/source/ImageWMS.js +24 -0
- package/lib/source/OGCMapTile.js +24 -0
- package/lib/source/OGCVectorTile.js +24 -0
- package/lib/source/OSM.js +24 -0
- package/lib/source/Raster.js +24 -0
- package/lib/source/Source.js +24 -0
- package/lib/source/Stamen.js +24 -0
- package/lib/source/Tile.js +24 -0
- package/lib/source/TileArcGISRest.js +24 -0
- package/lib/source/TileDebug.js +24 -0
- package/lib/source/TileImage.js +24 -0
- package/lib/source/TileJSON.js +24 -0
- package/lib/source/TileWMS.js +24 -0
- package/lib/source/UTFGrid.js +24 -0
- package/lib/source/UrlTile.js +24 -0
- package/lib/source/Vector.js +24 -0
- package/lib/source/VectorTile.js +24 -0
- package/lib/source/WMTS.js +24 -0
- package/lib/source/XYZ.js +24 -0
- package/lib/source/Zoomify.js +24 -0
- package/package.json +52 -17
- package/readme.md +44 -35
- package/renderer/render.js +304 -0
- package/renderer/update.js +98 -0
- package/.npmignore +0 -2
- package/common.js +0 -505
- package/debug.js +0 -88354
- package/embed.js +0 -293
- package/explorer.js +0 -464
- package/ol.css +0 -241
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
import BaseLayer from 'ol/layer/Base.js';
|
|
2
|
+
import Control from 'ol/control/Control.js';
|
|
3
|
+
import GroupLayer from 'ol/layer/Group.js';
|
|
4
|
+
import Interaction from 'ol/interaction/Interaction.js';
|
|
5
|
+
import Overlay from 'ol/Overlay.js';
|
|
6
|
+
import ReactReconciler from 'react-reconciler';
|
|
7
|
+
import Source from 'ol/source/Source.js';
|
|
8
|
+
import View from 'ol/View.js';
|
|
9
|
+
import {CONTROL, INTERACTION, LAYER, OVERLAY, SOURCE, VIEW} from '../config.js';
|
|
10
|
+
import {ConcurrentRoot, DefaultEventPriority} from 'react-reconciler/constants';
|
|
11
|
+
import {
|
|
12
|
+
prepareControlUpdate,
|
|
13
|
+
prepareInteractionUpdate,
|
|
14
|
+
prepareLayerUpdate,
|
|
15
|
+
prepareOverlayUpdate,
|
|
16
|
+
prepareSourceUpdate,
|
|
17
|
+
prepareViewUpdate,
|
|
18
|
+
reservedProps,
|
|
19
|
+
} from './update.js';
|
|
20
|
+
|
|
21
|
+
const listenerRegex = /^on([A-Z].*)/;
|
|
22
|
+
|
|
23
|
+
function upperFirst(str) {
|
|
24
|
+
return str[0].toUpperCase() + str.slice(1);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function setterName(str) {
|
|
28
|
+
return 'set' + upperFirst(str);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const knownTypes = {
|
|
32
|
+
[VIEW]: true,
|
|
33
|
+
[OVERLAY]: true,
|
|
34
|
+
[CONTROL]: true,
|
|
35
|
+
[INTERACTION]: true,
|
|
36
|
+
[LAYER]: true,
|
|
37
|
+
[SOURCE]: true,
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export function updateInstanceFromProps(instance, props, oldProps = {}) {
|
|
41
|
+
for (const key in props) {
|
|
42
|
+
if (reservedProps[key]) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
if (listenerRegex.test(key)) {
|
|
46
|
+
const listener = props[key];
|
|
47
|
+
const type = key.replace(listenerRegex, '$1').toLowerCase();
|
|
48
|
+
instance.on(type, listener);
|
|
49
|
+
if (oldProps[key]) {
|
|
50
|
+
instance.un(type, oldProps[key]);
|
|
51
|
+
}
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const setter = setterName(key);
|
|
56
|
+
if (typeof instance[setter] === 'function') {
|
|
57
|
+
instance[setter](props[key]);
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (key === 'features' && typeof instance.addFeatures === 'function') {
|
|
62
|
+
// TODO: there is likely a smarter way to diff features
|
|
63
|
+
instance.clear(true);
|
|
64
|
+
instance.addFeatures(props[key]);
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (
|
|
69
|
+
key === 'interactions' &&
|
|
70
|
+
typeof instance.addInteraction === 'function'
|
|
71
|
+
) {
|
|
72
|
+
instance.getInteractions().clear();
|
|
73
|
+
props[key].forEach(interaction => instance.addInteraction(interaction));
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (key === 'controls' && typeof instance.addControl === 'function') {
|
|
77
|
+
instance.getControls().clear();
|
|
78
|
+
props[key].forEach(control => instance.addControl(control));
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
throw new Error(`Cannot update '${key}' property`);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function createInstance(type, {cls: Constructor, ...props}) {
|
|
87
|
+
if (!knownTypes[type]) {
|
|
88
|
+
throw new Error(`Unsupported element type: ${type}`);
|
|
89
|
+
}
|
|
90
|
+
if (!Constructor) {
|
|
91
|
+
throw new Error(`No constructor for type: ${type}`);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const instance = new Constructor(props.options || {});
|
|
95
|
+
updateInstanceFromProps(instance, props);
|
|
96
|
+
return instance;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function createTextInstance() {
|
|
100
|
+
throw new Error('Cannot add text to the map');
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function appendChildToContainer(map, child) {
|
|
104
|
+
if (child instanceof View) {
|
|
105
|
+
map.setView(child);
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
if (child instanceof Overlay) {
|
|
109
|
+
map.addOverlay(child);
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (child instanceof Control) {
|
|
113
|
+
map.addControl(child);
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
if (child instanceof Interaction) {
|
|
117
|
+
map.addInteraction(child);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (child instanceof BaseLayer) {
|
|
121
|
+
map.addLayer(child);
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
throw new Error(`Cannot add child to the map: ${child}`);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function appendChild(parent, child) {
|
|
128
|
+
if (child instanceof Source) {
|
|
129
|
+
if (!(parent instanceof BaseLayer)) {
|
|
130
|
+
throw new Error(`Cannot add source to ${parent}`);
|
|
131
|
+
}
|
|
132
|
+
parent.setSource(child);
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
// Layer groups are an instance of a layer
|
|
136
|
+
if (child instanceof BaseLayer && parent instanceof GroupLayer) {
|
|
137
|
+
parent.getLayers().push(child);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
throw new Error(`Cannot add ${child} to ${parent}`);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const updaters = {
|
|
144
|
+
[VIEW]: prepareViewUpdate,
|
|
145
|
+
[OVERLAY]: prepareOverlayUpdate,
|
|
146
|
+
[CONTROL]: prepareControlUpdate,
|
|
147
|
+
[INTERACTION]: prepareInteractionUpdate,
|
|
148
|
+
[LAYER]: prepareLayerUpdate,
|
|
149
|
+
[SOURCE]: prepareSourceUpdate,
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
function prepareUpdate(instance, type, oldProps, newProps) {
|
|
153
|
+
const updater = updaters[type];
|
|
154
|
+
if (!updater) {
|
|
155
|
+
throw new Error(`Unsupported element type: ${type}`);
|
|
156
|
+
}
|
|
157
|
+
return updater(instance, type, oldProps, newProps);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function commitUpdate(instance, updatePayload, type, oldProps) {
|
|
161
|
+
updateInstanceFromProps(instance, updatePayload, oldProps);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function removeChildFromContainer(map, child) {
|
|
165
|
+
if (child instanceof View) {
|
|
166
|
+
map.setView(child);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (child instanceof Overlay) {
|
|
170
|
+
map.removeOverlay(child);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
if (child instanceof Control) {
|
|
174
|
+
map.removeControl(child);
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (child instanceof Interaction) {
|
|
178
|
+
map.removeInteraction(child);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (child instanceof BaseLayer) {
|
|
182
|
+
map.removeLayer(child);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
throw new Error(`Cannot remove child from the map: ${child}`);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function clearContainer(map) {
|
|
189
|
+
map.getLayers().clear();
|
|
190
|
+
// Need to leave the default controls and interactions.
|
|
191
|
+
// TODO: determine when this gets called.
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function insertInCollection(collection, child, beforeChild) {
|
|
195
|
+
const index = collection.getArray().indexOf(beforeChild);
|
|
196
|
+
if (index < 0) {
|
|
197
|
+
collection.push(child);
|
|
198
|
+
} else {
|
|
199
|
+
collection.insertAt(index, child);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function insertInContainerBefore(map, child, beforeChild) {
|
|
204
|
+
if (child instanceof View) {
|
|
205
|
+
map.setView(child);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
let collection;
|
|
209
|
+
if (child instanceof Overlay) {
|
|
210
|
+
collection = map.getOverlays();
|
|
211
|
+
} else if (child instanceof Control) {
|
|
212
|
+
collection = map.getControls();
|
|
213
|
+
} else if (child instanceof Interaction) {
|
|
214
|
+
collection = map.getInetracations();
|
|
215
|
+
} else if (child instanceof BaseLayer) {
|
|
216
|
+
collection = map.getLayers();
|
|
217
|
+
}
|
|
218
|
+
if (collection) {
|
|
219
|
+
insertInCollection(collection, child, beforeChild);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
function insertBefore(parent, child, beforeChild) {
|
|
224
|
+
if (child instanceof BaseLayer && parent instanceof GroupLayer) {
|
|
225
|
+
insertInCollection(parent.getLayers(), child, beforeChild);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
throw new Error(`Cannot insert child ${child} into parent ${parent}`);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
const reconciler = ReactReconciler({
|
|
232
|
+
supportsMutation: true,
|
|
233
|
+
isPrimaryRenderer: false,
|
|
234
|
+
createInstance,
|
|
235
|
+
createTextInstance,
|
|
236
|
+
appendChildToContainer,
|
|
237
|
+
appendChild,
|
|
238
|
+
appendInitialChild: appendChild,
|
|
239
|
+
prepareUpdate,
|
|
240
|
+
commitUpdate,
|
|
241
|
+
clearContainer,
|
|
242
|
+
removeChildFromContainer,
|
|
243
|
+
|
|
244
|
+
removeChild() {
|
|
245
|
+
throw new Error('TODO: implement removeChild');
|
|
246
|
+
},
|
|
247
|
+
|
|
248
|
+
insertInContainerBefore,
|
|
249
|
+
insertBefore,
|
|
250
|
+
|
|
251
|
+
finalizeInitialChildren() {
|
|
252
|
+
return false;
|
|
253
|
+
},
|
|
254
|
+
|
|
255
|
+
getChildHostContext() {},
|
|
256
|
+
|
|
257
|
+
getPublicInstance(instance) {
|
|
258
|
+
return instance;
|
|
259
|
+
},
|
|
260
|
+
|
|
261
|
+
getRootHostContext() {},
|
|
262
|
+
|
|
263
|
+
getCurrentEventPriority() {
|
|
264
|
+
return DefaultEventPriority;
|
|
265
|
+
},
|
|
266
|
+
|
|
267
|
+
prepareForCommit() {
|
|
268
|
+
return null;
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
resetAfterCommit() {},
|
|
272
|
+
|
|
273
|
+
shouldSetTextContent() {
|
|
274
|
+
return false;
|
|
275
|
+
},
|
|
276
|
+
|
|
277
|
+
detachDeletedInstance() {},
|
|
278
|
+
});
|
|
279
|
+
|
|
280
|
+
const roots = new Map();
|
|
281
|
+
|
|
282
|
+
export function render(element, container) {
|
|
283
|
+
let root = roots.get(container);
|
|
284
|
+
if (!root) {
|
|
285
|
+
const logRecoverableError =
|
|
286
|
+
typeof reportError === 'function'
|
|
287
|
+
? reportError // eslint-disable-line no-undef
|
|
288
|
+
: console.error; // eslint-disable-line no-console
|
|
289
|
+
|
|
290
|
+
root = reconciler.createContainer(
|
|
291
|
+
container,
|
|
292
|
+
ConcurrentRoot,
|
|
293
|
+
null,
|
|
294
|
+
false,
|
|
295
|
+
null,
|
|
296
|
+
'',
|
|
297
|
+
logRecoverableError,
|
|
298
|
+
null
|
|
299
|
+
);
|
|
300
|
+
roots.set(container, root);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
reconciler.updateContainer(element, root, null, null);
|
|
304
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function arrayEquals(a, b) {
|
|
2
|
+
if (a.length !== b.length) {
|
|
3
|
+
return false;
|
|
4
|
+
}
|
|
5
|
+
for (let i = 0; i < a.length; i++) {
|
|
6
|
+
if (a[i] !== b[i]) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const reservedProps = {
|
|
14
|
+
children: true,
|
|
15
|
+
cls: true,
|
|
16
|
+
options: true,
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function prepareViewUpdate(view, type, oldProps, newProps) {
|
|
20
|
+
if (view.getAnimating()) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
const payload = {};
|
|
24
|
+
let needsUpdate = false;
|
|
25
|
+
for (const key in newProps) {
|
|
26
|
+
if (reservedProps[key]) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
if (key === 'center') {
|
|
30
|
+
if (
|
|
31
|
+
!(
|
|
32
|
+
arrayEquals(oldProps.center, newProps.center) ||
|
|
33
|
+
arrayEquals(view.getCenter(), newProps.center)
|
|
34
|
+
)
|
|
35
|
+
) {
|
|
36
|
+
payload.center = newProps.center;
|
|
37
|
+
needsUpdate = true;
|
|
38
|
+
}
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (key === 'zoom') {
|
|
42
|
+
if (
|
|
43
|
+
!(oldProps.zoom === newProps.zoom || view.getZoom() === newProps.zoom)
|
|
44
|
+
) {
|
|
45
|
+
payload.zoom = newProps.zoom;
|
|
46
|
+
needsUpdate = true;
|
|
47
|
+
}
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (key === 'rotation') {
|
|
51
|
+
if (
|
|
52
|
+
!(
|
|
53
|
+
oldProps.rotation === newProps.rotation ||
|
|
54
|
+
view.getRotation() === newProps.rotation
|
|
55
|
+
)
|
|
56
|
+
) {
|
|
57
|
+
payload.rotation = newProps.rotation;
|
|
58
|
+
needsUpdate = true;
|
|
59
|
+
}
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
if (newProps[key] !== oldProps[key]) {
|
|
63
|
+
payload[key] = newProps[key];
|
|
64
|
+
needsUpdate = true;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
if (!needsUpdate) {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return payload;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function prepareGenericUpdate(instance, type, oldProps, newProps) {
|
|
74
|
+
const payload = {};
|
|
75
|
+
let needsUpdate = false;
|
|
76
|
+
for (const key in newProps) {
|
|
77
|
+
if (reservedProps[key]) {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (newProps[key] !== oldProps[key]) {
|
|
82
|
+
payload[key] = newProps[key];
|
|
83
|
+
needsUpdate = true;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (!needsUpdate) {
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
return payload;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export {
|
|
93
|
+
prepareGenericUpdate as prepareOverlayUpdate,
|
|
94
|
+
prepareGenericUpdate as prepareLayerUpdate,
|
|
95
|
+
prepareGenericUpdate as prepareSourceUpdate,
|
|
96
|
+
prepareGenericUpdate as prepareControlUpdate,
|
|
97
|
+
prepareGenericUpdate as prepareInteractionUpdate,
|
|
98
|
+
};
|
package/.npmignore
DELETED