@geolonia/embed 2.1.0 → 2.1.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/dist/embed +1 -1
- package/dist/embed.js +1 -1
- package/package.json +3 -3
- package/src/embed.js +10 -0
- package/src/lib/geolonia-map.js +6 -0
- package/src/style.css +24 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geolonia/embed",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Geolonia embed JS API",
|
|
5
5
|
"main": "dist/embed.js",
|
|
6
6
|
"types": "src/embed.d.ts",
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
"webpack-dev-server": "^4.3.1"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@geolonia/mbgl-geolonia-control": "^0.4.
|
|
53
|
+
"@geolonia/mbgl-geolonia-control": "^0.4.2",
|
|
54
54
|
"@geolonia/mbgl-gesture-handling": "^1.0.15",
|
|
55
55
|
"@mapbox/geojson-extent": "^0.3.2",
|
|
56
56
|
"@turf/center": "^6.0.1",
|
|
57
57
|
"core-js": "^3.6.5",
|
|
58
58
|
"intersection-observer": "^0.5.1",
|
|
59
|
-
"maplibre-gl": "
|
|
59
|
+
"maplibre-gl": "1.15.2",
|
|
60
60
|
"promise-polyfill": "^8.1.0",
|
|
61
61
|
"sanitize-html": "^2.3.2",
|
|
62
62
|
"tinycolor2": "^1.4.1",
|
package/src/embed.js
CHANGED
|
@@ -33,6 +33,16 @@ if ( util.checkPermission() ) {
|
|
|
33
33
|
map[isRemoved] = true;
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
// remove map instance automatically if the container removed.
|
|
37
|
+
// prevent memory leak
|
|
38
|
+
const observer = new MutationObserver((mutationRecords) => {
|
|
39
|
+
const removed = mutationRecords.some((record) => [...record.removedNodes].some((node) => node === target));
|
|
40
|
+
if (removed && !map[isRemoved]) {
|
|
41
|
+
map.remove();
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
observer.observe(target.parentNode, { childList: true });
|
|
45
|
+
|
|
36
46
|
// plugin
|
|
37
47
|
const atts = parseAtts(target);
|
|
38
48
|
if (isDOMContentLoaded && !map[isRemoved]) {
|
package/src/lib/geolonia-map.js
CHANGED
|
@@ -280,4 +280,10 @@ export default class GeoloniaMap extends maplibregl.Map {
|
|
|
280
280
|
// Calls `maplibregl.Map.setStyle()`.
|
|
281
281
|
super.setStyle.call(this, style, options);
|
|
282
282
|
}
|
|
283
|
+
|
|
284
|
+
remove() {
|
|
285
|
+
const container = this.getContainer();
|
|
286
|
+
super.remove.call(this);
|
|
287
|
+
delete container.geoloniaMap;
|
|
288
|
+
}
|
|
283
289
|
}
|
package/src/style.css
CHANGED
|
@@ -109,3 +109,27 @@
|
|
|
109
109
|
background-position: center center;
|
|
110
110
|
background-size: cover;
|
|
111
111
|
}
|
|
112
|
+
|
|
113
|
+
/* CSS for Attribution */
|
|
114
|
+
/* Fix: https://github.com/geolonia/embed/issues/291 */
|
|
115
|
+
.mapboxgl-map,
|
|
116
|
+
.maplibregl-map {
|
|
117
|
+
display: block!important;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.maplibregl-ctrl-attrib-inner.mapboxgl-ctrl-attrib-inner {
|
|
121
|
+
display: block!important;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-inner,
|
|
125
|
+
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-inner {
|
|
126
|
+
display: none!important;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
.mapboxgl-ctrl-attrib.mapboxgl-compact-show .mapboxgl-ctrl-attrib-inner,
|
|
130
|
+
.mapboxgl-ctrl-attrib.mapboxgl-compact .mapboxgl-ctrl-attrib-button,
|
|
131
|
+
.maplibregl-ctrl-attrib.maplibregl-compact-show .maplibregl-ctrl-attrib-inner,
|
|
132
|
+
.maplibregl-ctrl-attrib.maplibregl-compact .maplibregl-ctrl-attrib-button {
|
|
133
|
+
display: block!important;
|
|
134
|
+
}
|
|
135
|
+
/* End: CSS for Attribution */
|