@geolonia/embed 3.0.0-pre.1 → 3.0.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.
- package/.eslintrc.js +1 -1
- package/.github/workflows/build.yml +1 -1
- package/dist/embed +1 -1
- package/dist/embed-chunks/32f7b26f64d2caa77f2b.js +2 -0
- package/dist/embed-chunks/{9c922d7b054813866369.js.LICENSE.txt → 32f7b26f64d2caa77f2b.js.LICENSE.txt} +0 -0
- package/dist/embed-chunks/3d467b2d527e4e5de1b8.js +1 -0
- package/dist/embed.js +1 -1
- package/package.json +29 -27
- package/src/embed.d.ts +4 -0
- package/src/embed.js +0 -1
- package/src/lib/CustomAttributionControl.js +25 -3
- package/src/lib/parse-api-key.js +3 -4
- package/src/lib/simplestyle-vector.js +3 -6
- package/src/lib/simplestyle.js +3 -6
- package/src/lib/simplestyle.test.js +1 -0
- package/dist/embed-chunks/5ae1cbf5b6a878d13f8b.js +0 -1
- package/dist/embed-chunks/9c922d7b054813866369.js +0 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@geolonia/embed",
|
|
3
|
-
"version": "3.0.0
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"description": "Geolonia embed JS API",
|
|
5
5
|
"main": "dist/embed.js",
|
|
6
6
|
"types": "src/embed.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"analyze": "ANALYZE=true webpack --mode production",
|
|
11
11
|
"format": "prettier-eslint \"./src/**/*.js\" --write",
|
|
12
12
|
"lint": "eslint \"src/**/*.js\"",
|
|
13
|
-
"test": "
|
|
13
|
+
"test": "yarn run lint && mocha ./src/**/*.test.js --recursive -r jsdom-global/register -r @babel/register"
|
|
14
14
|
},
|
|
15
15
|
"author": "Geolonia (https://geolonia.com)",
|
|
16
16
|
"repository": {
|
|
@@ -23,42 +23,44 @@
|
|
|
23
23
|
},
|
|
24
24
|
"homepage": "https://github.com/geolonia/embed#readme",
|
|
25
25
|
"devDependencies": {
|
|
26
|
-
"@babel/cli": "^7.
|
|
27
|
-
"@babel/core": "^7.
|
|
28
|
-
"@babel/plugin-transform-classes": "^7.
|
|
29
|
-
"@babel/preset-env": "^7.
|
|
30
|
-
"@babel/register": "^7.
|
|
26
|
+
"@babel/cli": "^7.19.3",
|
|
27
|
+
"@babel/core": "^7.20.5",
|
|
28
|
+
"@babel/plugin-transform-classes": "^7.20.2",
|
|
29
|
+
"@babel/preset-env": "^7.20.2",
|
|
30
|
+
"@babel/register": "^7.18.9",
|
|
31
31
|
"@geolonia/eslint-config": "^0.0.1",
|
|
32
|
-
"babel-
|
|
33
|
-
"babel-loader": "^
|
|
34
|
-
"css-loader": "^
|
|
35
|
-
"eslint": "^
|
|
36
|
-
"jsdom": "^
|
|
32
|
+
"@babel/eslint-parser": "^7.19.1",
|
|
33
|
+
"babel-loader": "^9.1.0",
|
|
34
|
+
"css-loader": "^6.7.2",
|
|
35
|
+
"eslint": "^8.29.0",
|
|
36
|
+
"jsdom": "^20.0.3",
|
|
37
37
|
"jsdom-global": "^3.0.2",
|
|
38
|
-
"mocha": "^
|
|
38
|
+
"mocha": "^10.2.0",
|
|
39
39
|
"node-fetch": "2",
|
|
40
|
-
"prettier-eslint": "^
|
|
41
|
-
"prettier-eslint-cli": "^
|
|
42
|
-
"style-loader": "^
|
|
40
|
+
"prettier-eslint": "^15.0.0",
|
|
41
|
+
"prettier-eslint-cli": "^7.1.0",
|
|
42
|
+
"style-loader": "^3.3.1",
|
|
43
43
|
"svg-inline-loader": "^0.8.2",
|
|
44
|
-
"webpack": "^5.
|
|
45
|
-
"webpack-bundle-analyzer": "^4.
|
|
46
|
-
"webpack-cli": "^
|
|
47
|
-
"webpack-dev-server": "^4.
|
|
44
|
+
"webpack": "^5.75.0",
|
|
45
|
+
"webpack-bundle-analyzer": "^4.7.0",
|
|
46
|
+
"webpack-cli": "^5.0.1",
|
|
47
|
+
"webpack-dev-server": "^4.11.1"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@geolonia/mbgl-geolonia-control": "^0.4.2",
|
|
51
51
|
"@geolonia/mbgl-gesture-handling": "^1.0.15",
|
|
52
|
-
"@mapbox/geojson-extent": "^0.
|
|
52
|
+
"@mapbox/geojson-extent": "^1.0.0",
|
|
53
53
|
"@mapbox/point-geometry": "^0.1.0",
|
|
54
54
|
"@turf/center": "^6.0.1",
|
|
55
|
-
"core-js": "^3.
|
|
56
|
-
"intersection-observer": "^0.5.1",
|
|
55
|
+
"core-js": "^3.26.1",
|
|
57
56
|
"maplibre-gl": "2.4.0",
|
|
58
|
-
"promise-polyfill": "^8.
|
|
59
|
-
"sanitize-html": "^2.
|
|
57
|
+
"promise-polyfill": "^8.2.3",
|
|
58
|
+
"sanitize-html": "^2.8.0",
|
|
60
59
|
"tinycolor2": "^1.4.1",
|
|
61
|
-
"url-parse": "^1.
|
|
60
|
+
"url-parse": "^1.5.10",
|
|
62
61
|
"whatwg-fetch": "^3.0.0"
|
|
63
|
-
}
|
|
62
|
+
},
|
|
63
|
+
"browserslist": [
|
|
64
|
+
"defaults or >= 1% in JP"
|
|
65
|
+
]
|
|
64
66
|
}
|
package/src/embed.d.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import * as maplibregl from 'maplibre-gl';
|
|
2
|
+
import SimpleStyle from './lib/simplestyle'
|
|
2
3
|
|
|
3
4
|
export class Map extends maplibregl.Map {}
|
|
4
5
|
export class Marker extends maplibregl.Marker {}
|
|
6
|
+
export class Popup extends maplibregl.Popup {}
|
|
5
7
|
|
|
6
8
|
export type EmbedAttributes = {
|
|
7
9
|
lat: string;
|
|
@@ -45,6 +47,8 @@ declare global {
|
|
|
45
47
|
baseApiUrl: string;
|
|
46
48
|
Map: typeof Map;
|
|
47
49
|
Marker: typeof Marker;
|
|
50
|
+
Popup: typeof Popup;
|
|
51
|
+
SimpleStyle: typeof SimpleStyle;
|
|
48
52
|
registerPlugin: (embedPlugin: EmbedPlugin) => void;
|
|
49
53
|
}
|
|
50
54
|
}
|
package/src/embed.js
CHANGED
|
@@ -5,6 +5,23 @@ import { DOM, bindAll } from './maplibre-util';
|
|
|
5
5
|
* https://github.com/maplibre/maplibre-gl-js/blob/main/src/ui/control/attribution_control.ts
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* When the map is too small to display the full attribution, it will be
|
|
10
|
+
* collapsed in to a "i" icon. It is open by default, and will hide itself
|
|
11
|
+
* when user interaction is detected.
|
|
12
|
+
* For more information on why this is open by default, see the following links:
|
|
13
|
+
*
|
|
14
|
+
* The OSM Foundation attribution guidelines.
|
|
15
|
+
* https://wiki.osmfoundation.org/wiki/Licence/Attribution_Guidelines#Interactive_maps
|
|
16
|
+
* > You may use a mechanism to fade/collapse the attribution under certain conditions:
|
|
17
|
+
* > * immediately with a dismiss interaction, for example clicking an ‘x’ in the corner of a dialog
|
|
18
|
+
* > * automatically on map interaction such as panning, clicking, or zooming
|
|
19
|
+
* > * automatically after five seconds. This also applies to splash screens or pop-ups.
|
|
20
|
+
*
|
|
21
|
+
* This is the issue where attribution is open by default in the MapLibre GL JS library:
|
|
22
|
+
* https://github.com/maplibre/maplibre-gl-js/issues/205
|
|
23
|
+
*/
|
|
24
|
+
|
|
8
25
|
class CustomAttributionControl {
|
|
9
26
|
|
|
10
27
|
constructor(options = {}) {
|
|
@@ -48,13 +65,16 @@ class CustomAttributionControl {
|
|
|
48
65
|
const style = document.createElement('style');
|
|
49
66
|
style.textContent = `
|
|
50
67
|
.maplibregl-ctrl {
|
|
68
|
+
font: 12px/20px Helvetica Neue,Arial,Helvetica,sans-serif;
|
|
51
69
|
clear: both;
|
|
52
70
|
pointer-events: auto;
|
|
53
71
|
transform: translate(0);
|
|
54
72
|
}
|
|
73
|
+
|
|
55
74
|
.maplibregl-ctrl-attrib-button:focus,.maplibregl-ctrl-group button:focus {
|
|
56
75
|
box-shadow: 0 0 2px 2px #0096ff
|
|
57
76
|
}
|
|
77
|
+
|
|
58
78
|
.maplibregl-ctrl.maplibregl-ctrl-attrib {
|
|
59
79
|
background-color: hsla(0,0%,100%,.5);
|
|
60
80
|
margin: 0;
|
|
@@ -66,15 +86,17 @@ class CustomAttributionControl {
|
|
|
66
86
|
background-color: #fff;
|
|
67
87
|
border-radius: 12px;
|
|
68
88
|
box-sizing: content-box;
|
|
69
|
-
margin: 10px;
|
|
70
89
|
min-height: 20px;
|
|
71
90
|
padding: 2px 24px 2px 0;
|
|
72
|
-
position: relative
|
|
91
|
+
position: relative;
|
|
92
|
+
margin: 10px 10px 10px auto;
|
|
93
|
+
width: 0;
|
|
73
94
|
}
|
|
74
95
|
|
|
75
96
|
.maplibregl-ctrl-attrib.maplibregl-compact-show {
|
|
76
97
|
padding: 2px 28px 2px 8px;
|
|
77
|
-
visibility: visible
|
|
98
|
+
visibility: visible;
|
|
99
|
+
width: auto;
|
|
78
100
|
}
|
|
79
101
|
|
|
80
102
|
.maplibregl-ctrl-bottom-left>.maplibregl-ctrl-attrib.maplibregl-compact-show,.maplibregl-ctrl-top-left>.maplibregl-ctrl-attrib.maplibregl-compact-show {
|
package/src/lib/parse-api-key.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import urlParse from 'url-parse';
|
|
2
|
-
import querystring from 'querystring';
|
|
3
2
|
|
|
4
3
|
export default (document) => {
|
|
5
4
|
if (typeof window.geolonia === 'undefined') {
|
|
@@ -21,10 +20,10 @@ export default (document) => {
|
|
|
21
20
|
|
|
22
21
|
for (const script of scripts) {
|
|
23
22
|
const { pathname, query } = urlParse(script.src);
|
|
24
|
-
const q =
|
|
23
|
+
const q = new URLSearchParams(query.replace(/^\?/, ''));
|
|
25
24
|
|
|
26
|
-
if (q
|
|
27
|
-
params.key = q
|
|
25
|
+
if (q.get('geolonia-api-key')) {
|
|
26
|
+
params.key = q.get('geolonia-api-key') || 'YOUR-API-KEY';
|
|
28
27
|
|
|
29
28
|
const res = pathname.match( /^\/(v[0-9.]+)\/embed/ );
|
|
30
29
|
if (res && res[1]) {
|
|
@@ -152,7 +152,7 @@ class SimpleStyleVector {
|
|
|
152
152
|
type: 'circle',
|
|
153
153
|
source: this.sourceName,
|
|
154
154
|
'source-layer': 'g-simplestyle-v1',
|
|
155
|
-
filter: ['==', '$type', 'Point'],
|
|
155
|
+
filter: ['all', ['==', '$type', 'Point'], ['!has', 'marker-symbol']],
|
|
156
156
|
paint: {
|
|
157
157
|
'circle-radius': [
|
|
158
158
|
'case',
|
|
@@ -180,11 +180,7 @@ class SimpleStyleVector {
|
|
|
180
180
|
'text-halo-width': 1,
|
|
181
181
|
},
|
|
182
182
|
layout: {
|
|
183
|
-
'icon-image': [
|
|
184
|
-
'case',
|
|
185
|
-
['==', 'large', ['get', 'marker-size']], ['image', ['concat', ['get', 'marker-symbol'], '-15']],
|
|
186
|
-
['image', ['concat', ['get', 'marker-symbol'], '-11']],
|
|
187
|
-
],
|
|
183
|
+
'icon-image': ['get', 'marker-symbol'],
|
|
188
184
|
'text-field': ['get', 'title'],
|
|
189
185
|
'text-font': ['Noto Sans Regular'],
|
|
190
186
|
'text-size': 12,
|
|
@@ -201,6 +197,7 @@ class SimpleStyleVector {
|
|
|
201
197
|
});
|
|
202
198
|
|
|
203
199
|
this.setPopup(map, 'vt-circle-simple-style-points');
|
|
200
|
+
this.setPopup(map, 'vt-geolonia-simple-style-points');
|
|
204
201
|
}
|
|
205
202
|
|
|
206
203
|
async setPopup(map, source) {
|
package/src/lib/simplestyle.js
CHANGED
|
@@ -196,7 +196,7 @@ class SimpleStyle {
|
|
|
196
196
|
id: `${this.options.id}-circle-points`,
|
|
197
197
|
type: 'circle',
|
|
198
198
|
source: `${this.options.id}-points`,
|
|
199
|
-
filter: ['
|
|
199
|
+
filter: ['all', ['!has', 'point_count'], ['!has', 'marker-symbol']],
|
|
200
200
|
paint: {
|
|
201
201
|
'circle-radius': [
|
|
202
202
|
'case',
|
|
@@ -223,11 +223,7 @@ class SimpleStyle {
|
|
|
223
223
|
'text-halo-width': 1,
|
|
224
224
|
},
|
|
225
225
|
layout: {
|
|
226
|
-
'icon-image': [
|
|
227
|
-
'case',
|
|
228
|
-
['==', 'large', ['get', 'marker-size']], ['image', ['concat', ['get', 'marker-symbol'], '-15']],
|
|
229
|
-
['image', ['concat', ['get', 'marker-symbol'], '-11']],
|
|
230
|
-
],
|
|
226
|
+
'icon-image': ['get', 'marker-symbol'],
|
|
231
227
|
'text-field': ['get', 'title'],
|
|
232
228
|
'text-font': ['Noto Sans Regular'],
|
|
233
229
|
'text-size': 12,
|
|
@@ -244,6 +240,7 @@ class SimpleStyle {
|
|
|
244
240
|
});
|
|
245
241
|
|
|
246
242
|
this.setPopup(this.map, `${this.options.id}-circle-points`);
|
|
243
|
+
this.setPopup(this.map, `${this.options.id}-symbol-points`);
|
|
247
244
|
}
|
|
248
245
|
|
|
249
246
|
async setPopup(map, source) {
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(self.webpackChunk_geolonia_embed=self.webpackChunk_geolonia_embed||[]).push([[841],{5347:()=>{},1777:()=>{},4017:()=>{},9905:()=>{},4604:()=>{}}]);
|