react-spatial 1.2.2 → 1.2.3-beta.3
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/LayerService.js +128 -184
- package/LayerService.js.map +7 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js +163 -221
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.js.map +7 -1
- package/components/BaseLayerSwitcher/index.js +1 -3
- package/components/BaseLayerSwitcher/index.js.map +7 -1
- package/components/BasicMap/BasicMap.js +147 -285
- package/components/BasicMap/BasicMap.js.map +7 -1
- package/components/BasicMap/index.js +1 -3
- package/components/BasicMap/index.js.map +7 -1
- package/components/CanvasSaveButton/CanvasSaveButton.js +165 -419
- package/components/CanvasSaveButton/CanvasSaveButton.js.map +7 -1
- package/components/CanvasSaveButton/index.js +1 -3
- package/components/CanvasSaveButton/index.js.map +7 -1
- package/components/Copyright/Copyright.js +29 -70
- package/components/Copyright/Copyright.js.map +7 -1
- package/components/Copyright/index.js +1 -3
- package/components/Copyright/index.js.map +7 -1
- package/components/FeatureExportButton/FeatureExportButton.js +40 -106
- package/components/FeatureExportButton/FeatureExportButton.js.map +7 -1
- package/components/FeatureExportButton/index.js +1 -3
- package/components/FeatureExportButton/index.js.map +7 -1
- package/components/FilterButton/FilterButton.js +41 -106
- package/components/FilterButton/FilterButton.js.map +7 -1
- package/components/FilterButton/index.js +1 -3
- package/components/FilterButton/index.js.map +7 -1
- package/components/FitExtent/FitExtent.js +17 -50
- package/components/FitExtent/FitExtent.js.map +7 -1
- package/components/FitExtent/index.js +1 -3
- package/components/FitExtent/index.js.map +7 -1
- package/components/FollowButton/FollowButton.js +41 -111
- package/components/FollowButton/FollowButton.js.map +7 -1
- package/components/FollowButton/index.js +1 -3
- package/components/FollowButton/index.js.map +7 -1
- package/components/Geolocation/Geolocation.js +104 -213
- package/components/Geolocation/Geolocation.js.map +7 -1
- package/components/Geolocation/index.js +1 -3
- package/components/Geolocation/index.js.map +7 -1
- package/components/LayerTree/LayerTree.js +204 -410
- package/components/LayerTree/LayerTree.js.map +7 -1
- package/components/LayerTree/index.js +1 -3
- package/components/LayerTree/index.js.map +7 -1
- package/components/MousePosition/MousePosition.js +61 -130
- package/components/MousePosition/MousePosition.js.map +7 -1
- package/components/MousePosition/index.js +1 -3
- package/components/MousePosition/index.js.map +7 -1
- package/components/NorthArrow/NorthArrow.js +22 -62
- package/components/NorthArrow/NorthArrow.js.map +7 -1
- package/components/NorthArrow/index.js +1 -3
- package/components/NorthArrow/index.js.map +7 -1
- package/components/Overlay/Overlay.js +83 -130
- package/components/Overlay/Overlay.js.map +7 -1
- package/components/Overlay/index.js +1 -3
- package/components/Overlay/index.js.map +7 -1
- package/components/Permalink/Permalink.js +150 -244
- package/components/Permalink/Permalink.js.map +7 -1
- package/components/Permalink/index.js +1 -3
- package/components/Permalink/index.js.map +7 -1
- package/components/Popup/Popup.js +106 -233
- package/components/Popup/Popup.js.map +7 -1
- package/components/Popup/index.js +1 -3
- package/components/Popup/index.js.map +7 -1
- package/components/ResizeHandler/ResizeHandler.js +58 -113
- package/components/ResizeHandler/ResizeHandler.js.map +7 -1
- package/components/ResizeHandler/index.js +1 -3
- package/components/ResizeHandler/index.js.map +7 -1
- package/components/RouteSchedule/RouteSchedule.js +150 -283
- package/components/RouteSchedule/RouteSchedule.js.map +7 -1
- package/components/RouteSchedule/index.js +1 -3
- package/components/RouteSchedule/index.js.map +7 -1
- package/components/ScaleLine/ScaleLine.js +21 -45
- package/components/ScaleLine/ScaleLine.js.map +7 -1
- package/components/ScaleLine/index.js +1 -3
- package/components/ScaleLine/index.js.map +7 -1
- package/components/Search/Search.js +122 -186
- package/components/Search/Search.js.map +7 -1
- package/components/Search/SearchService.js +45 -69
- package/components/Search/SearchService.js.map +7 -1
- package/components/Search/engines/Engine.js +18 -25
- package/components/Search/engines/Engine.js.map +7 -1
- package/components/Search/engines/StopFinder.js +21 -38
- package/components/Search/engines/StopFinder.js.map +7 -1
- package/components/Search/index.js +3 -6
- package/components/Search/index.js.map +7 -1
- package/components/StopsFinder/StopsFinder.js +123 -174
- package/components/StopsFinder/StopsFinder.js.map +7 -1
- package/components/StopsFinder/StopsFinderOption.js +37 -54
- package/components/StopsFinder/StopsFinderOption.js.map +7 -1
- package/components/StopsFinder/index.js +1 -3
- package/components/StopsFinder/index.js.map +7 -1
- package/components/TrackerControl/TrackerControl.js +73 -128
- package/components/TrackerControl/TrackerControl.js.map +7 -1
- package/components/TrackerControl/index.js +1 -3
- package/components/TrackerControl/index.js.map +7 -1
- package/components/Zoom/Zoom.js +69 -112
- package/components/Zoom/Zoom.js.map +7 -1
- package/components/Zoom/index.js +1 -3
- package/components/Zoom/index.js.map +7 -1
- package/package.json +10 -5
- package/propTypes.js +17 -23
- package/propTypes.js.map +7 -1
- package/setupTests.js +2 -4
- package/setupTests.js.map +7 -1
- package/themes/README.md +26 -0
- package/themes/default/components.scss +0 -1
- package/themes/default/examples.scss +0 -1
- package/utils/GlobalsForOle.js +63 -64
- package/utils/GlobalsForOle.js.map +7 -1
- package/utils/KML.js +178 -364
- package/utils/KML.js.map +7 -1
- package/utils/KMLFormat.js +37 -73
- package/utils/KMLFormat.js.map +7 -1
- package/utils/Styles.js +24 -32
- package/utils/Styles.js.map +7 -1
- package/utils/getPolygonPattern.js +11 -44
- package/utils/getPolygonPattern.js.map +7 -1
- package/utils/timeUtils.js +16 -35
- package/utils/timeUtils.js.map +7 -1
- package/LayerService.test.js +0 -160
- package/LayerService.test.js.map +0 -1
- package/Projections.js +0 -16
- package/Projections.js.map +0 -1
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js +0 -88
- package/components/BaseLayerSwitcher/BaseLayerSwitcher.test.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.js +0 -490
- package/components/BaseLayerToggler/BaseLayerToggler.js.map +0 -1
- package/components/BaseLayerToggler/BaseLayerToggler.md.scss +0 -9
- package/components/BaseLayerToggler/BaseLayerToggler.scss +0 -49
- package/components/BaseLayerToggler/BaseLayerToggler.test.js +0 -127
- package/components/BaseLayerToggler/BaseLayerToggler.test.js.map +0 -1
- package/components/BaseLayerToggler/index.js +0 -3
- package/components/BaseLayerToggler/index.js.map +0 -1
- package/components/BasicMap/BasicMap.test.js +0 -288
- package/components/BasicMap/BasicMap.test.js.map +0 -1
- package/components/CanvasSaveButton/CanvasSaveButton.test.js +0 -173
- package/components/CanvasSaveButton/CanvasSaveButton.test.js.map +0 -1
- package/components/Copyright/Copyright.test.js +0 -133
- package/components/Copyright/Copyright.test.js.map +0 -1
- package/components/FeatureExportButton/FeatureExportButton.test.js +0 -407
- package/components/FeatureExportButton/FeatureExportButton.test.js.map +0 -1
- package/components/FilterButton/FilterButton.test.js +0 -48
- package/components/FilterButton/FilterButton.test.js.map +0 -1
- package/components/FitExtent/FitExtent.test.js +0 -44
- package/components/FitExtent/FitExtent.test.js.map +0 -1
- package/components/FollowButton/FollowButton.test.js +0 -57
- package/components/FollowButton/FollowButton.test.js.map +0 -1
- package/components/Geolocation/Geolocation.test.js +0 -263
- package/components/Geolocation/Geolocation.test.js.map +0 -1
- package/components/LayerTree/LayerTree.test.js +0 -323
- package/components/LayerTree/LayerTree.test.js.map +0 -1
- package/components/MousePosition/MousePosition.test.js +0 -125
- package/components/MousePosition/MousePosition.test.js.map +0 -1
- package/components/NorthArrow/NorthArrow.test.js +0 -106
- package/components/NorthArrow/NorthArrow.test.js.map +0 -1
- package/components/Overlay/Overlay.test.js +0 -145
- package/components/Overlay/Overlay.test.js.map +0 -1
- package/components/Permalink/Permalink.test.js +0 -267
- package/components/Permalink/Permalink.test.js.map +0 -1
- package/components/Popup/Popup.test.js +0 -291
- package/components/Popup/Popup.test.js.map +0 -1
- package/components/ResizeHandler/ResizeHandler.test.js +0 -410
- package/components/ResizeHandler/ResizeHandler.test.js.map +0 -1
- package/components/RouteSchedule/RouteSchedule.test.js +0 -102
- package/components/RouteSchedule/RouteSchedule.test.js.map +0 -1
- package/components/ScaleLine/ScaleLine.test.js +0 -32
- package/components/ScaleLine/ScaleLine.test.js.map +0 -1
- package/components/Search/Search.test.js +0 -15
- package/components/Search/Search.test.js.map +0 -1
- package/components/StopsFinder/StopsFinder.test.js +0 -19
- package/components/StopsFinder/StopsFinder.test.js.map +0 -1
- package/components/TrackerControl/TrackerControl.test.js +0 -17
- package/components/TrackerControl/TrackerControl.test.js.map +0 -1
- package/components/Zoom/Zoom.test.js +0 -150
- package/components/Zoom/Zoom.test.js.map +0 -1
- package/styleguidist/ComponentsList.js +0 -52
- package/styleguidist/ComponentsList.js.map +0 -1
- package/styleguidist/StyleGuide.js +0 -253
- package/styleguidist/StyleGuide.js.map +0 -1
- package/utils/KML.test.js +0 -163
- package/utils/KML.test.js.map +0 -1
- package/utils/KMLFormat.test.js +0 -22
- package/utils/KMLFormat.test.js.map +0 -1
- package/utils/getPolygonPattern.test.js +0 -66
- package/utils/getPolygonPattern.test.js.map +0 -1
- package/utils/timeUtils.test.js +0 -32
- package/utils/timeUtils.test.js.map +0 -1
package/utils/KML.js
CHANGED
|
@@ -1,289 +1,201 @@
|
|
|
1
|
-
import KML from
|
|
2
|
-
import { Feature } from
|
|
3
|
-
import Point from
|
|
4
|
-
import MultiPoint from
|
|
5
|
-
import GeometryCollection from
|
|
6
|
-
import { Style, Text, Icon, Circle, Fill, Stroke } from
|
|
7
|
-
import { asString } from
|
|
8
|
-
import { parse } from
|
|
9
|
-
import { kmlStyle } from
|
|
10
|
-
import getPolygonPattern from
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
import KML from "ol/format/KML";
|
|
2
|
+
import { Feature } from "ol";
|
|
3
|
+
import Point from "ol/geom/Point";
|
|
4
|
+
import MultiPoint from "ol/geom/MultiPoint";
|
|
5
|
+
import GeometryCollection from "ol/geom/GeometryCollection";
|
|
6
|
+
import { Style, Text, Icon, Circle, Fill, Stroke } from "ol/style";
|
|
7
|
+
import { asString } from "ol/color";
|
|
8
|
+
import { parse } from "ol/xml";
|
|
9
|
+
import { kmlStyle } from "./Styles";
|
|
10
|
+
import getPolygonPattern from "./getPolygonPattern";
|
|
11
|
+
const applyTextStyleForIcon = (olIcon, olText) => {
|
|
12
|
+
const size = olIcon.getSize() || [48, 48];
|
|
13
|
+
const scale = olIcon.getScale() || 1;
|
|
14
|
+
const anchor = olIcon.getAnchor() || [
|
|
15
|
+
size[0] * scale / 2,
|
|
16
|
+
size[1] * scale / 2
|
|
17
|
+
];
|
|
18
|
+
const offset = [
|
|
19
19
|
scale * (size[0] - anchor[0]) + 5,
|
|
20
|
-
scale * (size[1] / 2 - anchor[1])
|
|
20
|
+
scale * (size[1] / 2 - anchor[1])
|
|
21
|
+
];
|
|
21
22
|
olText.setOffsetX(offset[0]);
|
|
22
23
|
olText.setOffsetY(offset[1]);
|
|
23
|
-
olText.setTextAlign(
|
|
24
|
+
olText.setTextAlign("left");
|
|
24
25
|
};
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if ( index === void 0 ) index = 0;
|
|
29
|
-
|
|
30
|
-
var coords = geom.getCoordinates();
|
|
31
|
-
var len = coords.length - 1;
|
|
26
|
+
const getVertexCoord = (geom, start = true, index = 0) => {
|
|
27
|
+
const coords = geom.getCoordinates();
|
|
28
|
+
const len = coords.length - 1;
|
|
32
29
|
return start ? coords[index] : coords[len - index];
|
|
33
30
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
var dx = start ? coordA[0] - coordB[0] : coordB[0] - coordA[0];
|
|
42
|
-
var dy = start ? coordA[1] - coordB[1] : coordB[1] - coordA[1];
|
|
43
|
-
var rotation = Math.atan2(dy, dx);
|
|
44
|
-
|
|
31
|
+
const getLineIcon = (feature, icon, color, start = true) => {
|
|
32
|
+
const geom = feature.getGeometry();
|
|
33
|
+
const coordA = getVertexCoord(geom, start, 1);
|
|
34
|
+
const coordB = getVertexCoord(geom, start);
|
|
35
|
+
const dx = start ? coordA[0] - coordB[0] : coordB[0] - coordA[0];
|
|
36
|
+
const dy = start ? coordA[1] - coordB[1] : coordB[1] - coordA[1];
|
|
37
|
+
const rotation = Math.atan2(dy, dx);
|
|
45
38
|
return new Style({
|
|
46
|
-
geometry:
|
|
47
|
-
|
|
39
|
+
geometry: (feat) => {
|
|
40
|
+
const ge = feat.getGeometry();
|
|
48
41
|
return new Point(getVertexCoord(ge, start));
|
|
49
42
|
},
|
|
50
43
|
image: new Icon({
|
|
51
44
|
src: icon.url,
|
|
52
|
-
color
|
|
45
|
+
color,
|
|
53
46
|
rotation: -rotation,
|
|
54
47
|
rotateWithView: true,
|
|
55
48
|
scale: icon.scale,
|
|
56
|
-
imgSize: icon.size
|
|
49
|
+
imgSize: icon.size
|
|
57
50
|
}),
|
|
58
|
-
zIndex: icon.zIndex
|
|
51
|
+
zIndex: icon.zIndex
|
|
59
52
|
});
|
|
60
53
|
};
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
// Store maxZoom in properties
|
|
68
|
-
if (feature.get('maxZoom')) {
|
|
69
|
-
feature.set('maxZoom', parseFloat(feature.get('maxZoom'), 10));
|
|
54
|
+
const sanitizeFeature = (feature) => {
|
|
55
|
+
const geom = feature.getGeometry();
|
|
56
|
+
let styles = feature.getStyleFunction();
|
|
57
|
+
if (feature.get("maxZoom")) {
|
|
58
|
+
feature.set("maxZoom", parseFloat(feature.get("maxZoom"), 10));
|
|
70
59
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
if (feature.get('minZoom')) {
|
|
74
|
-
feature.set('minZoom', parseFloat(feature.get('minZoom'), 10));
|
|
60
|
+
if (feature.get("minZoom")) {
|
|
61
|
+
feature.set("minZoom", parseFloat(feature.get("minZoom"), 10));
|
|
75
62
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
var stroke = style.getStroke();
|
|
82
|
-
if (stroke && feature.get('lineDash')) {
|
|
63
|
+
const tmpStyles = styles(feature);
|
|
64
|
+
const style = (Array.isArray(tmpStyles) ? tmpStyles[0] : tmpStyles).clone();
|
|
65
|
+
let stroke = style.getStroke();
|
|
66
|
+
if (stroke && feature.get("lineDash")) {
|
|
83
67
|
stroke.setLineDash(
|
|
84
|
-
feature
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
.map(function (l) {
|
|
88
|
-
return parseInt(l, 10);
|
|
89
|
-
})
|
|
68
|
+
feature.get("lineDash").split(",").map((l) => {
|
|
69
|
+
return parseInt(l, 10);
|
|
70
|
+
})
|
|
90
71
|
);
|
|
91
72
|
}
|
|
92
|
-
|
|
93
|
-
// The canvas draws a stroke width=1 by default if width=0, so we
|
|
94
|
-
// remove the stroke style in that case.
|
|
95
73
|
if (stroke && stroke.getWidth() === 0) {
|
|
96
|
-
stroke =
|
|
74
|
+
stroke = void 0;
|
|
97
75
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
style.setZIndex(parseInt(feature.get('zIndex'), 10));
|
|
76
|
+
if (feature.get("zIndex")) {
|
|
77
|
+
style.setZIndex(parseInt(feature.get("zIndex"), 10));
|
|
101
78
|
}
|
|
102
|
-
|
|
103
|
-
// if the feature is a Point and we are offline, we use default vector
|
|
104
|
-
// style.
|
|
105
|
-
// if the feature is a Point and has a name with a text style, we
|
|
106
|
-
// create a correct text style.
|
|
107
|
-
// TODO Handle GeometryCollection displaying name on the first Point
|
|
108
|
-
// geometry.
|
|
109
79
|
if (style && (geom instanceof Point || geom instanceof MultiPoint)) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
// If the feature has name we display it on the map as Google does
|
|
115
|
-
if (
|
|
116
|
-
feature.get('name') &&
|
|
117
|
-
style.getText() &&
|
|
118
|
-
style.getText().getScale() !== 0
|
|
119
|
-
) {
|
|
80
|
+
let image = style.getImage();
|
|
81
|
+
let text = null;
|
|
82
|
+
let fill = style.getFill();
|
|
83
|
+
if (feature.get("name") && style.getText() && style.getText().getScale() !== 0) {
|
|
120
84
|
if (image && image.getScale() === 0) {
|
|
121
|
-
// transparentCircle is used to allow selection
|
|
122
85
|
image = new Circle({
|
|
123
86
|
radius: 1,
|
|
124
87
|
fill: new Fill({ color: [0, 0, 0, 0] }),
|
|
125
|
-
stroke: new Stroke({ color: [0, 0, 0, 0] })
|
|
88
|
+
stroke: new Stroke({ color: [0, 0, 0, 0] })
|
|
126
89
|
});
|
|
127
90
|
}
|
|
128
|
-
|
|
129
|
-
// We replace empty white spaces used to keep normal spaces before and after the name.
|
|
130
|
-
var name = feature.get('name');
|
|
91
|
+
let name = feature.get("name");
|
|
131
92
|
if (/\u200B/g.test(name)) {
|
|
132
|
-
name = name.replace(/\u200B/g,
|
|
133
|
-
feature.set(
|
|
93
|
+
name = name.replace(/\u200B/g, "");
|
|
94
|
+
feature.set("name", name);
|
|
134
95
|
}
|
|
135
|
-
|
|
136
96
|
text = new Text({
|
|
137
|
-
font: feature.get(
|
|
138
|
-
text: feature.get(
|
|
97
|
+
font: feature.get("textFont") || "normal 16px Helvetica",
|
|
98
|
+
text: feature.get("name"),
|
|
139
99
|
fill: style.getText().getFill(),
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
// since ol 6.3.1 : https://github.com/openlayers/openlayers/pull/10613/files#diff-1883da8b57e690db7ea0c35ce53c880aR925
|
|
143
|
-
// a default textstroke is added to mimic google earth.
|
|
144
|
-
// it was not the case before, the stroke was always null. So to keep
|
|
145
|
-
// the same behavior we don't copy the stroke style.
|
|
146
|
-
// TODO : maybe we should use this functionnality in the futur.
|
|
147
|
-
// stroke: style.getText().getStroke(),
|
|
148
|
-
scale: style.getText().getScale(),
|
|
100
|
+
rotation: feature.get("textRotation") || 0,
|
|
101
|
+
scale: style.getText().getScale()
|
|
149
102
|
});
|
|
150
|
-
|
|
151
|
-
if (feature.get('textStrokeColor') && feature.get('textStrokeWidth')) {
|
|
103
|
+
if (feature.get("textStrokeColor") && feature.get("textStrokeWidth")) {
|
|
152
104
|
text.setStroke(
|
|
153
105
|
new Stroke({
|
|
154
|
-
color: feature.get(
|
|
155
|
-
width: parseFloat(feature.get(
|
|
106
|
+
color: feature.get("textStrokeColor"),
|
|
107
|
+
width: parseFloat(feature.get("textStrokeWidth"))
|
|
156
108
|
})
|
|
157
109
|
);
|
|
158
110
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
text.setTextAlign(feature.get('textAlign'));
|
|
111
|
+
if (feature.get("textAlign")) {
|
|
112
|
+
text.setTextAlign(feature.get("textAlign"));
|
|
162
113
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
text.setOffsetX(parseFloat(feature.get('textOffsetX')));
|
|
114
|
+
if (feature.get("textOffsetX")) {
|
|
115
|
+
text.setOffsetX(parseFloat(feature.get("textOffsetX")));
|
|
166
116
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
text.setOffsetY(parseFloat(feature.get('textOffsetY')));
|
|
117
|
+
if (feature.get("textOffsetY")) {
|
|
118
|
+
text.setOffsetY(parseFloat(feature.get("textOffsetY")));
|
|
170
119
|
}
|
|
171
|
-
|
|
172
|
-
if (feature.get('textBackgroundFillColor')) {
|
|
120
|
+
if (feature.get("textBackgroundFillColor")) {
|
|
173
121
|
text.setBackgroundFill(
|
|
174
122
|
new Fill({
|
|
175
|
-
color: feature.get(
|
|
123
|
+
color: feature.get("textBackgroundFillColor")
|
|
176
124
|
})
|
|
177
125
|
);
|
|
178
126
|
}
|
|
179
|
-
|
|
180
|
-
if (feature.get('textPadding')) {
|
|
127
|
+
if (feature.get("textPadding")) {
|
|
181
128
|
text.setPadding(
|
|
182
|
-
feature
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
.map(function (n) {
|
|
186
|
-
return parseFloat(n);
|
|
187
|
-
})
|
|
129
|
+
feature.get("textPadding").split(",").map((n) => {
|
|
130
|
+
return parseFloat(n);
|
|
131
|
+
})
|
|
188
132
|
);
|
|
189
133
|
}
|
|
190
|
-
|
|
191
134
|
if (image instanceof Icon) {
|
|
192
135
|
applyTextStyleForIcon(image, text);
|
|
193
136
|
}
|
|
194
137
|
}
|
|
195
|
-
|
|
196
138
|
if (image instanceof Icon) {
|
|
197
|
-
|
|
198
|
-
* <heading> tag, which is not read as rotation value by the ol KML module)
|
|
199
|
-
*/
|
|
200
|
-
image.setRotation(parseFloat(feature.get('iconRotation')) || 0);
|
|
139
|
+
image.setRotation(parseFloat(feature.get("iconRotation")) || 0);
|
|
201
140
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
* a resolution attribute (this is the map resolution at the zoom level when
|
|
209
|
-
* the picture is created), can take an optional constant for further scale
|
|
210
|
-
* adjustment.
|
|
211
|
-
* e.g. { resolution: 0.123, defaultScale: 1 / 6 }
|
|
212
|
-
*/
|
|
213
|
-
|
|
214
|
-
if (feat.get('pictureOptions')) {
|
|
215
|
-
var pictureOptions = feat.get('pictureOptions');
|
|
216
|
-
if (typeof pictureOptions === 'string') {
|
|
141
|
+
fill = void 0;
|
|
142
|
+
stroke = void 0;
|
|
143
|
+
styles = (feat, resolution) => {
|
|
144
|
+
if (feat.get("pictureOptions")) {
|
|
145
|
+
let pictureOptions = feat.get("pictureOptions");
|
|
146
|
+
if (typeof pictureOptions === "string") {
|
|
217
147
|
pictureOptions = JSON.parse(pictureOptions);
|
|
218
148
|
}
|
|
219
|
-
feat.set(
|
|
149
|
+
feat.set("pictureOptions", pictureOptions);
|
|
220
150
|
if (pictureOptions.resolution) {
|
|
221
151
|
image.setScale(
|
|
222
|
-
|
|
223
|
-
pictureOptions.defaultScale || 1
|
|
152
|
+
pictureOptions.resolution / resolution * pictureOptions.defaultScale || 1
|
|
224
153
|
);
|
|
225
154
|
}
|
|
226
155
|
}
|
|
227
|
-
|
|
228
156
|
return new Style({
|
|
229
|
-
fill
|
|
230
|
-
stroke
|
|
231
|
-
image
|
|
232
|
-
text
|
|
233
|
-
zIndex: style.getZIndex()
|
|
157
|
+
fill,
|
|
158
|
+
stroke,
|
|
159
|
+
image,
|
|
160
|
+
text,
|
|
161
|
+
zIndex: style.getZIndex()
|
|
234
162
|
});
|
|
235
163
|
};
|
|
236
164
|
}
|
|
237
|
-
|
|
238
|
-
// Remove image and text styles for polygons and lines
|
|
239
|
-
if (
|
|
240
|
-
!(
|
|
241
|
-
geom instanceof Point ||
|
|
242
|
-
geom instanceof MultiPoint ||
|
|
243
|
-
geom instanceof GeometryCollection
|
|
244
|
-
)
|
|
245
|
-
) {
|
|
165
|
+
if (!(geom instanceof Point || geom instanceof MultiPoint || geom instanceof GeometryCollection)) {
|
|
246
166
|
styles = [
|
|
247
167
|
new Style({
|
|
248
168
|
fill: style.getFill(),
|
|
249
|
-
stroke
|
|
169
|
+
stroke,
|
|
250
170
|
image: null,
|
|
251
171
|
text: null,
|
|
252
|
-
zIndex: style.getZIndex()
|
|
253
|
-
})
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
var fillPattern = feature.get('fillPattern');
|
|
172
|
+
zIndex: style.getZIndex()
|
|
173
|
+
})
|
|
174
|
+
];
|
|
175
|
+
let fillPattern = feature.get("fillPattern");
|
|
257
176
|
if (fillPattern) {
|
|
258
177
|
fillPattern = JSON.parse(fillPattern);
|
|
259
|
-
feature.set(
|
|
260
|
-
|
|
261
|
-
/* We set the fill pattern for polygons */
|
|
178
|
+
feature.set("fillPattern", fillPattern);
|
|
262
179
|
if (!style.getFill()) {
|
|
263
180
|
styles[0].setFill(new Fill());
|
|
264
181
|
}
|
|
265
|
-
|
|
266
|
-
? [0, 0, 0, 0]
|
|
267
|
-
: getPolygonPattern(fillPattern.id, fillPattern.color);
|
|
182
|
+
const patternOrColor = fillPattern.empty ? [0, 0, 0, 0] : getPolygonPattern(fillPattern.id, fillPattern.color);
|
|
268
183
|
styles[0].getFill().setColor(patternOrColor);
|
|
269
184
|
}
|
|
270
|
-
|
|
271
|
-
// Add line's icons styles
|
|
272
|
-
if (feature.get('lineStartIcon')) {
|
|
185
|
+
if (feature.get("lineStartIcon")) {
|
|
273
186
|
styles.push(
|
|
274
187
|
getLineIcon(
|
|
275
188
|
feature,
|
|
276
|
-
JSON.parse(feature.get(
|
|
189
|
+
JSON.parse(feature.get("lineStartIcon")),
|
|
277
190
|
stroke.getColor()
|
|
278
191
|
)
|
|
279
192
|
);
|
|
280
193
|
}
|
|
281
|
-
|
|
282
|
-
if (feature.get('lineEndIcon')) {
|
|
194
|
+
if (feature.get("lineEndIcon")) {
|
|
283
195
|
styles.push(
|
|
284
196
|
getLineIcon(
|
|
285
197
|
feature,
|
|
286
|
-
JSON.parse(feature.get(
|
|
198
|
+
JSON.parse(feature.get("lineEndIcon")),
|
|
287
199
|
stroke.getColor(),
|
|
288
200
|
false
|
|
289
201
|
)
|
|
@@ -292,307 +204,209 @@ var sanitizeFeature = function (feature) {
|
|
|
292
204
|
}
|
|
293
205
|
feature.setStyle(styles);
|
|
294
206
|
};
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
* @param {String} kmlString A string representing a KML file.
|
|
299
|
-
* @param {<ol.Projection|String>} featureProjection The projection used by the map.
|
|
300
|
-
*/
|
|
301
|
-
var readFeatures = function (kmlString, featureProjection) {
|
|
302
|
-
var features = new KML().readFeatures(kmlString, {
|
|
303
|
-
featureProjection: featureProjection,
|
|
207
|
+
const readFeatures = (kmlString, featureProjection) => {
|
|
208
|
+
const features = new KML().readFeatures(kmlString, {
|
|
209
|
+
featureProjection
|
|
304
210
|
});
|
|
305
|
-
features.forEach(
|
|
211
|
+
features.forEach((feature) => {
|
|
306
212
|
sanitizeFeature(feature);
|
|
307
213
|
});
|
|
308
214
|
return features;
|
|
309
215
|
};
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
var writeFeatures = function (layer, featureProjection, mapResolution) {
|
|
317
|
-
var featString;
|
|
318
|
-
var olLayer = layer.olLayer;
|
|
319
|
-
var exportFeatures = [];
|
|
320
|
-
|
|
321
|
-
olLayer.getSource().forEachFeature(function (feature) {
|
|
322
|
-
// We silently ignore Circle elements as they are
|
|
323
|
-
// not supported in kml.
|
|
324
|
-
if (feature.getGeometry().getType() === 'Circle') {
|
|
216
|
+
const writeFeatures = (layer, featureProjection, mapResolution) => {
|
|
217
|
+
let featString;
|
|
218
|
+
const { olLayer } = layer;
|
|
219
|
+
const exportFeatures = [];
|
|
220
|
+
olLayer.getSource().forEachFeature((feature) => {
|
|
221
|
+
if (feature.getGeometry().getType() === "Circle") {
|
|
325
222
|
return;
|
|
326
223
|
}
|
|
327
|
-
|
|
328
|
-
var clone = feature.clone();
|
|
224
|
+
const clone = feature.clone();
|
|
329
225
|
clone.setId(feature.getId());
|
|
330
226
|
clone.getGeometry().setProperties(feature.getGeometry().getProperties());
|
|
331
|
-
clone.getGeometry().transform(featureProjection,
|
|
332
|
-
|
|
333
|
-
// We remove all ExtendedData not related to style.
|
|
334
|
-
Object.keys(feature.getProperties()).forEach(function (key) {
|
|
227
|
+
clone.getGeometry().transform(featureProjection, "EPSG:4326");
|
|
228
|
+
Object.keys(feature.getProperties()).forEach((key) => {
|
|
335
229
|
if (!/^(geometry|name|description)$/.test(key)) {
|
|
336
230
|
clone.unset(key, true);
|
|
337
231
|
}
|
|
338
232
|
});
|
|
339
|
-
|
|
340
|
-
var styles;
|
|
341
|
-
|
|
233
|
+
let styles;
|
|
342
234
|
if (feature.getStyleFunction()) {
|
|
343
235
|
styles = feature.getStyleFunction()(feature, mapResolution);
|
|
344
236
|
} else if (olLayer && olLayer.getStyleFunction()) {
|
|
345
237
|
styles = olLayer.getStyleFunction()(feature, mapResolution);
|
|
346
238
|
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
var newStyle = {
|
|
239
|
+
const mainStyle = styles[0] || styles;
|
|
240
|
+
const newStyle = {
|
|
351
241
|
fill: mainStyle.getFill(),
|
|
352
242
|
stroke: mainStyle.getStroke(),
|
|
353
243
|
text: mainStyle.getText(),
|
|
354
244
|
image: mainStyle.getImage(),
|
|
355
|
-
zIndex: mainStyle.getZIndex()
|
|
245
|
+
zIndex: mainStyle.getZIndex()
|
|
356
246
|
};
|
|
357
|
-
|
|
358
247
|
if (newStyle.zIndex) {
|
|
359
|
-
clone.set(
|
|
248
|
+
clone.set("zIndex", newStyle.zIndex);
|
|
360
249
|
}
|
|
361
|
-
|
|
362
|
-
// If we see spaces at the beginning or at the end we add a empty
|
|
363
|
-
// white space at the beginning and at the end.
|
|
364
250
|
if (newStyle.text && /^\s|\s$/g.test(newStyle.text.getText())) {
|
|
365
|
-
newStyle.text.setText(
|
|
251
|
+
newStyle.text.setText(`\u200B${newStyle.text.getText()}\u200B`);
|
|
366
252
|
}
|
|
367
|
-
|
|
368
|
-
// Set custom properties to be converted in extendedData in KML.
|
|
369
253
|
if (newStyle.text && newStyle.text.getRotation()) {
|
|
370
|
-
clone.set(
|
|
254
|
+
clone.set("textRotation", newStyle.text.getRotation());
|
|
371
255
|
}
|
|
372
|
-
|
|
373
256
|
if (newStyle.text && newStyle.text.getFont()) {
|
|
374
|
-
clone.set(
|
|
257
|
+
clone.set("textFont", newStyle.text.getFont());
|
|
375
258
|
}
|
|
376
|
-
|
|
377
259
|
if (newStyle.text && newStyle.text.getTextAlign()) {
|
|
378
|
-
clone.set(
|
|
260
|
+
clone.set("textAlign", newStyle.text.getTextAlign());
|
|
379
261
|
}
|
|
380
|
-
|
|
381
262
|
if (newStyle.text && newStyle.text.getOffsetX()) {
|
|
382
|
-
clone.set(
|
|
263
|
+
clone.set("textOffsetX", newStyle.text.getOffsetX());
|
|
383
264
|
}
|
|
384
|
-
|
|
385
265
|
if (newStyle.text && newStyle.text.getOffsetY()) {
|
|
386
|
-
clone.set(
|
|
266
|
+
clone.set("textOffsetY", newStyle.text.getOffsetY());
|
|
387
267
|
}
|
|
388
|
-
|
|
389
268
|
if (newStyle.text && newStyle.text.getStroke()) {
|
|
390
269
|
if (newStyle.text.getStroke().getColor()) {
|
|
391
270
|
clone.set(
|
|
392
|
-
|
|
271
|
+
"textStrokeColor",
|
|
393
272
|
asString(newStyle.text.getStroke().getColor())
|
|
394
273
|
);
|
|
395
274
|
}
|
|
396
|
-
|
|
397
275
|
if (newStyle.text.getStroke().getWidth()) {
|
|
398
|
-
clone.set(
|
|
276
|
+
clone.set("textStrokeWidth", newStyle.text.getStroke().getWidth());
|
|
399
277
|
}
|
|
400
278
|
}
|
|
401
|
-
|
|
402
279
|
if (newStyle.text && newStyle.text.getBackgroundFill()) {
|
|
403
280
|
clone.set(
|
|
404
|
-
|
|
281
|
+
"textBackgroundFillColor",
|
|
405
282
|
asString(newStyle.text.getBackgroundFill().getColor())
|
|
406
283
|
);
|
|
407
284
|
}
|
|
408
|
-
|
|
409
285
|
if (newStyle.text && newStyle.text.getPadding()) {
|
|
410
|
-
clone.set(
|
|
286
|
+
clone.set("textPadding", newStyle.text.getPadding().join());
|
|
411
287
|
}
|
|
412
|
-
|
|
413
288
|
if (newStyle.stroke && newStyle.stroke.getLineDash()) {
|
|
414
|
-
clone.set(
|
|
289
|
+
clone.set("lineDash", newStyle.stroke.getLineDash().join(","));
|
|
415
290
|
}
|
|
416
|
-
|
|
417
291
|
if (newStyle.image instanceof Circle) {
|
|
418
292
|
newStyle.image = null;
|
|
419
293
|
}
|
|
420
|
-
|
|
421
294
|
if (newStyle.image) {
|
|
422
|
-
|
|
295
|
+
const imgSource = newStyle.image.getSrc();
|
|
423
296
|
if (!/(http(s?)):\/\//gi.test(imgSource)) {
|
|
424
|
-
// eslint-disable-next-line no-console
|
|
425
297
|
console.log(
|
|
426
|
-
|
|
427
|
-
'Should use remote web server'
|
|
298
|
+
"Local image source not supported for KML export.Should use remote web server"
|
|
428
299
|
);
|
|
429
300
|
}
|
|
430
|
-
|
|
431
301
|
if (newStyle.image.getRotation()) {
|
|
432
|
-
|
|
433
|
-
clone.set('iconRotation', newStyle.image.getRotation());
|
|
302
|
+
clone.set("iconRotation", newStyle.image.getRotation());
|
|
434
303
|
}
|
|
435
|
-
|
|
436
|
-
// Set map resolution to use for icon-to-map proportional scaling
|
|
437
|
-
if (feature.get('pictureOptions')) {
|
|
304
|
+
if (feature.get("pictureOptions")) {
|
|
438
305
|
clone.set(
|
|
439
|
-
|
|
440
|
-
JSON.stringify(feature.get(
|
|
306
|
+
"pictureOptions",
|
|
307
|
+
JSON.stringify(feature.get("pictureOptions"))
|
|
441
308
|
);
|
|
442
309
|
}
|
|
443
310
|
}
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
if (feature.get('fillPattern')) {
|
|
447
|
-
clone.set('fillPattern', JSON.stringify(feature.get('fillPattern')));
|
|
311
|
+
if (feature.get("fillPattern")) {
|
|
312
|
+
clone.set("fillPattern", JSON.stringify(feature.get("fillPattern")));
|
|
448
313
|
newStyle.fill = null;
|
|
449
314
|
}
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
if (feature.get('maxZoom')) {
|
|
453
|
-
clone.set('maxZoom', parseFloat(feature.get('maxZoom'), 10));
|
|
315
|
+
if (feature.get("maxZoom")) {
|
|
316
|
+
clone.set("maxZoom", parseFloat(feature.get("maxZoom"), 10));
|
|
454
317
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
if (feature.get('minZoom')) {
|
|
458
|
-
clone.set('minZoom', parseFloat(feature.get('minZoom'), 10));
|
|
318
|
+
if (feature.get("minZoom")) {
|
|
319
|
+
clone.set("minZoom", parseFloat(feature.get("minZoom"), 10));
|
|
459
320
|
}
|
|
460
|
-
|
|
461
|
-
// If only text is displayed we must specify an
|
|
462
|
-
// image style with scale=0
|
|
463
321
|
if (newStyle.text && !newStyle.image) {
|
|
464
322
|
newStyle.image = new Icon({
|
|
465
|
-
src:
|
|
466
|
-
scale: 0
|
|
323
|
+
src: "noimage",
|
|
324
|
+
scale: 0
|
|
467
325
|
});
|
|
468
326
|
}
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
extraLineStyle &&
|
|
475
|
-
extraLineStyle.getImage() instanceof Icon &&
|
|
476
|
-
extraLineStyle.getGeometry()
|
|
477
|
-
) {
|
|
478
|
-
var coord = extraLineStyle.getGeometry()(feature).getCoordinates();
|
|
479
|
-
var startCoord = feature.getGeometry().getFirstCoordinate();
|
|
327
|
+
const extraLineStyles = Array.isArray(styles) && styles.slice(1) || [];
|
|
328
|
+
extraLineStyles.forEach((extraLineStyle) => {
|
|
329
|
+
if (extraLineStyle && extraLineStyle.getImage() instanceof Icon && extraLineStyle.getGeometry()) {
|
|
330
|
+
const coord = extraLineStyle.getGeometry()(feature).getCoordinates();
|
|
331
|
+
const startCoord = feature.getGeometry().getFirstCoordinate();
|
|
480
332
|
if (coord[0] === startCoord[0] && coord[1] === startCoord[1]) {
|
|
481
333
|
clone.set(
|
|
482
|
-
|
|
334
|
+
"lineStartIcon",
|
|
483
335
|
JSON.stringify({
|
|
484
336
|
url: extraLineStyle.getImage().getSrc(),
|
|
485
337
|
scale: extraLineStyle.getImage().getScale(),
|
|
486
338
|
size: extraLineStyle.getImage().getSize(),
|
|
487
|
-
zIndex: extraLineStyle.getZIndex()
|
|
339
|
+
zIndex: extraLineStyle.getZIndex()
|
|
488
340
|
})
|
|
489
341
|
);
|
|
490
342
|
} else {
|
|
491
343
|
clone.set(
|
|
492
|
-
|
|
344
|
+
"lineEndIcon",
|
|
493
345
|
JSON.stringify({
|
|
494
346
|
url: extraLineStyle.getImage().getSrc(),
|
|
495
347
|
scale: extraLineStyle.getImage().getScale(),
|
|
496
348
|
size: extraLineStyle.getImage().getSize(),
|
|
497
|
-
zIndex: extraLineStyle.getZIndex()
|
|
349
|
+
zIndex: extraLineStyle.getZIndex()
|
|
498
350
|
})
|
|
499
351
|
);
|
|
500
352
|
}
|
|
501
353
|
}
|
|
502
354
|
});
|
|
503
|
-
|
|
504
|
-
var olStyle = new Style(newStyle);
|
|
355
|
+
const olStyle = new Style(newStyle);
|
|
505
356
|
clone.setStyle(olStyle);
|
|
506
|
-
|
|
507
|
-
if (
|
|
508
|
-
!(
|
|
509
|
-
clone.getGeometry() instanceof Point &&
|
|
510
|
-
olStyle.getText() &&
|
|
511
|
-
!olStyle.getText().getText()
|
|
512
|
-
)
|
|
513
|
-
) {
|
|
357
|
+
if (!(clone.getGeometry() instanceof Point && olStyle.getText() && !olStyle.getText().getText())) {
|
|
514
358
|
exportFeatures.push(clone);
|
|
515
359
|
}
|
|
516
360
|
});
|
|
517
|
-
|
|
518
361
|
if (exportFeatures.length > 0) {
|
|
519
362
|
if (exportFeatures.length === 1) {
|
|
520
|
-
// force the add of a <Document> node
|
|
521
363
|
exportFeatures.push(new Feature());
|
|
522
364
|
}
|
|
523
|
-
|
|
524
365
|
featString = new KML({
|
|
525
366
|
extractStyles: true,
|
|
526
|
-
defaultStyle: [kmlStyle]
|
|
367
|
+
defaultStyle: [kmlStyle]
|
|
527
368
|
}).writeFeatures(exportFeatures);
|
|
528
|
-
|
|
529
|
-
// Remove no image hack
|
|
530
369
|
featString = featString.replace(
|
|
531
370
|
/<Icon>\s*<href>noimage<\/href>\s*<\/Icon>/g,
|
|
532
|
-
|
|
371
|
+
""
|
|
533
372
|
);
|
|
534
|
-
|
|
535
|
-
// Remove empty placemark added to have
|
|
536
|
-
// <Document> tag
|
|
537
|
-
featString = featString.replace(/<Placemark\/>/g, '');
|
|
538
|
-
|
|
539
|
-
// Add KML document name
|
|
373
|
+
featString = featString.replace(/<Placemark\/>/g, "");
|
|
540
374
|
if (layer.name) {
|
|
541
375
|
featString = featString.replace(
|
|
542
376
|
/<Document>/,
|
|
543
|
-
|
|
377
|
+
`<Document><name>${layer.name}</name>`
|
|
544
378
|
);
|
|
545
379
|
}
|
|
546
380
|
}
|
|
547
|
-
|
|
548
381
|
return featString;
|
|
549
382
|
};
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
* @param {String} kmlString A string representing a KML file.
|
|
554
|
-
*/
|
|
555
|
-
var removeDocumentCamera = function (kmlString) {
|
|
556
|
-
var kmlDoc = parse(kmlString);
|
|
557
|
-
// Remove old Camera node
|
|
558
|
-
var oldCameraNode = kmlDoc.getElementsByTagName('Camera')[0];
|
|
383
|
+
const removeDocumentCamera = (kmlString) => {
|
|
384
|
+
const kmlDoc = parse(kmlString);
|
|
385
|
+
const oldCameraNode = kmlDoc.getElementsByTagName("Camera")[0];
|
|
559
386
|
if (oldCameraNode) {
|
|
560
387
|
oldCameraNode.remove();
|
|
561
388
|
}
|
|
562
389
|
return new XMLSerializer().serializeToString(kmlDoc);
|
|
563
390
|
};
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
* Write the <Camera> tag into a KML string. Returns the KML string with added <Camera> tag.
|
|
567
|
-
* @param {String} kmlString A string representing a KML file.
|
|
568
|
-
* @param {Object} cameraAttributes Object containing the camera tags (longitude, latitude, altitude, heading, tilt, altitudeMode, roll)
|
|
569
|
-
* as keys with corresponding values. See https://developers.google.com/kml/documentation/kmlreference#camera
|
|
570
|
-
*/
|
|
571
|
-
var writeDocumentCamera = function (kmlString, cameraAttributes) {
|
|
572
|
-
var kmlDoc = parse(removeDocumentCamera(kmlString));
|
|
573
|
-
|
|
391
|
+
const writeDocumentCamera = (kmlString, cameraAttributes) => {
|
|
392
|
+
const kmlDoc = parse(removeDocumentCamera(kmlString));
|
|
574
393
|
if (cameraAttributes) {
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
("" + (key.charAt(0).toUpperCase() + key.slice(1)))
|
|
394
|
+
const cameraNode = kmlDoc.createElement("Camera");
|
|
395
|
+
Object.keys(cameraAttributes).forEach((key) => {
|
|
396
|
+
const cameraAttribute = kmlDoc.createElement(
|
|
397
|
+
`${key.charAt(0).toUpperCase() + key.slice(1)}`
|
|
580
398
|
);
|
|
581
399
|
cameraAttribute.innerHTML = cameraAttributes[key];
|
|
582
400
|
cameraNode.appendChild(cameraAttribute);
|
|
583
401
|
});
|
|
584
|
-
|
|
402
|
+
const documentNode = kmlDoc.getElementsByTagName("Document")[0];
|
|
585
403
|
documentNode.appendChild(cameraNode);
|
|
586
404
|
}
|
|
587
|
-
|
|
588
405
|
return new XMLSerializer().serializeToString(kmlDoc);
|
|
589
406
|
};
|
|
590
|
-
|
|
591
407
|
export default {
|
|
592
|
-
readFeatures
|
|
593
|
-
writeFeatures
|
|
594
|
-
writeDocumentCamera
|
|
595
|
-
removeDocumentCamera
|
|
408
|
+
readFeatures,
|
|
409
|
+
writeFeatures,
|
|
410
|
+
writeDocumentCamera,
|
|
411
|
+
removeDocumentCamera
|
|
596
412
|
};
|
|
597
|
-
|
|
598
|
-
//# sourceMappingURL=KML.js.map
|