umap-project 2.4.1__py3-none-any.whl → 2.5.0__py3-none-any.whl
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.
- umap/__init__.py +1 -1
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +145 -90
- umap/locale/en/LC_MESSAGES/django.po +13 -13
- umap/locale/eu/LC_MESSAGES/django.mo +0 -0
- umap/locale/eu/LC_MESSAGES/django.po +145 -89
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +100 -50
- umap/static/umap/base.css +5 -2
- umap/static/umap/content.css +2 -2
- umap/static/umap/css/contextmenu.css +11 -0
- umap/static/umap/css/dialog.css +25 -4
- umap/static/umap/css/importers.css +2 -0
- umap/static/umap/css/panel.css +6 -4
- umap/static/umap/css/slideshow.css +69 -0
- umap/static/umap/css/tableeditor.css +69 -0
- umap/static/umap/css/tooltip.css +3 -3
- umap/static/umap/img/16-white.svg +4 -0
- umap/static/umap/img/source/16-white.svg +5 -1
- umap/static/umap/js/components/alerts/alert.css +11 -11
- umap/static/umap/js/components/alerts/alert.js +1 -1
- umap/static/umap/js/modules/autocomplete.js +27 -5
- umap/static/umap/js/modules/browser.js +20 -14
- umap/static/umap/js/modules/caption.js +4 -4
- umap/static/umap/js/modules/dompurify.js +2 -3
- umap/static/umap/js/modules/facets.js +53 -17
- umap/static/umap/js/modules/formatter.js +153 -0
- umap/static/umap/js/modules/global.js +25 -16
- umap/static/umap/js/modules/help.js +26 -26
- umap/static/umap/js/modules/importer.js +10 -10
- umap/static/umap/js/modules/importers/communesfr.js +3 -1
- umap/static/umap/js/modules/importers/datasets.js +8 -6
- umap/static/umap/js/modules/importers/geodatamine.js +14 -14
- umap/static/umap/js/modules/importers/overpass.js +19 -15
- umap/static/umap/js/modules/orderable.js +2 -2
- umap/static/umap/js/modules/request.js +1 -1
- umap/static/umap/js/modules/rules.js +26 -11
- umap/static/umap/js/modules/schema.js +16 -12
- umap/static/umap/js/{umap.share.js → modules/share.js} +58 -103
- umap/static/umap/js/modules/slideshow.js +141 -0
- umap/static/umap/js/modules/sync/engine.js +3 -3
- umap/static/umap/js/modules/sync/updaters.js +10 -11
- umap/static/umap/js/modules/sync/websocket.js +1 -1
- umap/static/umap/js/modules/tableeditor.js +329 -0
- umap/static/umap/js/modules/ui/base.js +93 -0
- umap/static/umap/js/modules/ui/contextmenu.js +50 -0
- umap/static/umap/js/modules/ui/dialog.js +169 -31
- umap/static/umap/js/modules/ui/panel.js +7 -5
- umap/static/umap/js/modules/ui/tooltip.js +7 -77
- umap/static/umap/js/modules/urls.js +1 -2
- umap/static/umap/js/modules/utils.js +36 -16
- umap/static/umap/js/umap.controls.js +27 -29
- umap/static/umap/js/umap.core.js +19 -15
- umap/static/umap/js/umap.datalayer.permissions.js +15 -18
- umap/static/umap/js/umap.features.js +113 -131
- umap/static/umap/js/umap.forms.js +203 -228
- umap/static/umap/js/umap.icon.js +17 -22
- umap/static/umap/js/umap.js +117 -107
- umap/static/umap/js/umap.layer.js +374 -324
- umap/static/umap/js/umap.permissions.js +7 -10
- umap/static/umap/js/umap.popup.js +20 -20
- umap/static/umap/locale/am_ET.js +22 -5
- umap/static/umap/locale/am_ET.json +22 -5
- umap/static/umap/locale/ar.js +22 -5
- umap/static/umap/locale/ar.json +22 -5
- umap/static/umap/locale/ast.js +22 -5
- umap/static/umap/locale/ast.json +22 -5
- umap/static/umap/locale/bg.js +22 -5
- umap/static/umap/locale/bg.json +22 -5
- umap/static/umap/locale/br.js +22 -5
- umap/static/umap/locale/br.json +22 -5
- umap/static/umap/locale/ca.js +56 -39
- umap/static/umap/locale/ca.json +56 -39
- umap/static/umap/locale/cs_CZ.js +22 -5
- umap/static/umap/locale/cs_CZ.json +22 -5
- umap/static/umap/locale/da.js +22 -5
- umap/static/umap/locale/da.json +22 -5
- umap/static/umap/locale/de.js +22 -5
- umap/static/umap/locale/de.json +22 -5
- umap/static/umap/locale/el.js +27 -10
- umap/static/umap/locale/el.json +27 -10
- umap/static/umap/locale/en.js +22 -6
- umap/static/umap/locale/en.json +22 -6
- umap/static/umap/locale/en_US.json +22 -5
- umap/static/umap/locale/es.js +22 -6
- umap/static/umap/locale/es.json +22 -6
- umap/static/umap/locale/et.js +22 -5
- umap/static/umap/locale/et.json +22 -5
- umap/static/umap/locale/eu.js +167 -150
- umap/static/umap/locale/eu.json +167 -150
- umap/static/umap/locale/fa_IR.js +22 -5
- umap/static/umap/locale/fa_IR.json +22 -5
- umap/static/umap/locale/fi.js +22 -5
- umap/static/umap/locale/fi.json +22 -5
- umap/static/umap/locale/fr.js +22 -6
- umap/static/umap/locale/fr.json +22 -6
- umap/static/umap/locale/gl.js +22 -5
- umap/static/umap/locale/gl.json +22 -5
- umap/static/umap/locale/he.js +22 -5
- umap/static/umap/locale/he.json +22 -5
- umap/static/umap/locale/hr.js +22 -5
- umap/static/umap/locale/hr.json +22 -5
- umap/static/umap/locale/hu.js +89 -72
- umap/static/umap/locale/hu.json +89 -72
- umap/static/umap/locale/id.js +22 -5
- umap/static/umap/locale/id.json +22 -5
- umap/static/umap/locale/is.js +22 -5
- umap/static/umap/locale/is.json +22 -5
- umap/static/umap/locale/it.js +22 -5
- umap/static/umap/locale/it.json +22 -5
- umap/static/umap/locale/ja.js +22 -5
- umap/static/umap/locale/ja.json +22 -5
- umap/static/umap/locale/ko.js +22 -5
- umap/static/umap/locale/ko.json +22 -5
- umap/static/umap/locale/lt.js +22 -5
- umap/static/umap/locale/lt.json +22 -5
- umap/static/umap/locale/ms.js +22 -5
- umap/static/umap/locale/ms.json +22 -5
- umap/static/umap/locale/nl.js +22 -5
- umap/static/umap/locale/nl.json +22 -5
- umap/static/umap/locale/no.js +22 -5
- umap/static/umap/locale/no.json +22 -5
- umap/static/umap/locale/pl.js +22 -5
- umap/static/umap/locale/pl.json +22 -5
- umap/static/umap/locale/pl_PL.json +22 -5
- umap/static/umap/locale/pt.js +22 -6
- umap/static/umap/locale/pt.json +22 -6
- umap/static/umap/locale/pt_BR.js +22 -5
- umap/static/umap/locale/pt_BR.json +22 -5
- umap/static/umap/locale/pt_PT.js +22 -5
- umap/static/umap/locale/pt_PT.json +22 -5
- umap/static/umap/locale/ro.js +22 -5
- umap/static/umap/locale/ro.json +22 -5
- umap/static/umap/locale/ru.js +22 -5
- umap/static/umap/locale/ru.json +22 -5
- umap/static/umap/locale/sk_SK.js +22 -5
- umap/static/umap/locale/sk_SK.json +22 -5
- umap/static/umap/locale/sl.js +22 -5
- umap/static/umap/locale/sl.json +22 -5
- umap/static/umap/locale/sr.js +22 -5
- umap/static/umap/locale/sr.json +22 -5
- umap/static/umap/locale/sv.js +22 -5
- umap/static/umap/locale/sv.json +22 -5
- umap/static/umap/locale/th_TH.js +22 -5
- umap/static/umap/locale/th_TH.json +22 -5
- umap/static/umap/locale/tr.js +22 -5
- umap/static/umap/locale/tr.json +22 -5
- umap/static/umap/locale/uk_UA.js +22 -5
- umap/static/umap/locale/uk_UA.json +22 -5
- umap/static/umap/locale/vi.js +22 -5
- umap/static/umap/locale/vi.json +22 -5
- umap/static/umap/locale/vi_VN.json +22 -5
- umap/static/umap/locale/zh.js +22 -5
- umap/static/umap/locale/zh.json +22 -5
- umap/static/umap/locale/zh_CN.json +22 -5
- umap/static/umap/locale/zh_TW.Big5.json +22 -5
- umap/static/umap/locale/zh_TW.js +22 -5
- umap/static/umap/locale/zh_TW.json +22 -5
- umap/static/umap/map.css +9 -153
- umap/static/umap/vars.css +15 -0
- umap/static/umap/vendors/dompurify/purify.es.js +5 -59
- umap/static/umap/vendors/dompurify/purify.es.mjs.map +1 -1
- umap/static/umap/vendors/formbuilder/Leaflet.FormBuilder.js +410 -428
- umap/static/umap/vendors/geojson-to-gpx/index.js +155 -0
- umap/static/umap/vendors/osmtogeojson/osmtogeojson.js +1 -2
- umap/static/umap/vendors/togeojson/togeojson.es.js +1109 -0
- umap/static/umap/vendors/togeojson/{togeojson.umd.js.map → togeojson.es.mjs.map} +1 -1
- umap/static/umap/vendors/tokml/tokml.es.js +895 -0
- umap/static/umap/vendors/tokml/tokml.es.mjs.map +1 -0
- umap/storage.py +6 -2
- umap/templates/umap/components/alerts/alert.html +3 -3
- umap/templates/umap/css.html +3 -0
- umap/templates/umap/js.html +0 -6
- umap/tests/fixtures/categorized_highway.geojson +1 -0
- umap/tests/fixtures/test_import_osm_relation.json +130 -0
- umap/tests/integration/conftest.py +8 -1
- umap/tests/integration/test_browser.py +3 -2
- umap/tests/integration/test_categorized_layer.py +141 -0
- umap/tests/integration/test_conditional_rules.py +21 -0
- umap/tests/integration/test_datalayer.py +9 -4
- umap/tests/integration/test_edit_datalayer.py +1 -0
- umap/tests/integration/test_edit_polygon.py +1 -1
- umap/tests/integration/test_export_map.py +2 -3
- umap/tests/integration/test_import.py +22 -0
- umap/tests/integration/test_map_preview.py +36 -2
- umap/tests/integration/test_tableeditor.py +158 -4
- umap/tests/integration/test_websocket_sync.py +2 -2
- umap/tests/test_views.py +2 -2
- umap/views.py +3 -2
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/METADATA +8 -8
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/RECORD +194 -184
- umap/static/umap/js/umap.slideshow.js +0 -165
- umap/static/umap/js/umap.tableeditor.js +0 -118
- umap/static/umap/vendors/togeojson/togeojson.umd.js +0 -2
- umap/static/umap/vendors/togpx/togpx.js +0 -547
- umap/static/umap/vendors/tokml/tokml.js +0 -343
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/WHEEL +0 -0
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/entry_points.txt +0 -0
- {umap_project-2.4.1.dist-info → umap_project-2.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js'
|
|
2
2
|
import { translate } from '../i18n.js'
|
|
3
3
|
|
|
4
4
|
export class Panel {
|
|
@@ -9,7 +9,7 @@ export class Panel {
|
|
|
9
9
|
// This will be set once according to the panel configurated at load
|
|
10
10
|
// or by using panels as popups
|
|
11
11
|
this.mode = null
|
|
12
|
-
this.
|
|
12
|
+
this.className = 'left'
|
|
13
13
|
DomEvent.disableClickPropagation(this.container)
|
|
14
14
|
DomEvent.on(this.container, 'contextmenu', DomEvent.stopPropagation) // Do not activate our custom context menu.
|
|
15
15
|
DomEvent.on(this.container, 'wheel', DomEvent.stopPropagation)
|
|
@@ -25,9 +25,10 @@ export class Panel {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
open({ content, className, actions = [] } = {}) {
|
|
28
|
-
this.container.className = `with-transition panel window ${this.
|
|
28
|
+
this.container.className = `with-transition panel window ${this.className} ${
|
|
29
29
|
this.mode || ''
|
|
30
30
|
}`
|
|
31
|
+
document.body.classList.add(`panel-${this.className.split(' ')[0]}-on`)
|
|
31
32
|
this.container.innerHTML = ''
|
|
32
33
|
const actionsContainer = DomUtil.create('ul', 'buttons', this.container)
|
|
33
34
|
const body = DomUtil.create('div', 'body', this.container)
|
|
@@ -69,6 +70,7 @@ export class Panel {
|
|
|
69
70
|
}
|
|
70
71
|
|
|
71
72
|
close() {
|
|
73
|
+
document.body.classList.remove(`panel-${this.className.split(' ')[0]}-on`)
|
|
72
74
|
if (DomUtil.hasClass(this.container, 'on')) {
|
|
73
75
|
DomUtil.removeClass(this.container, 'on')
|
|
74
76
|
this.map.invalidateSize({ pan: false })
|
|
@@ -80,14 +82,14 @@ export class Panel {
|
|
|
80
82
|
export class EditPanel extends Panel {
|
|
81
83
|
constructor(map) {
|
|
82
84
|
super(map)
|
|
83
|
-
this.
|
|
85
|
+
this.className = 'right dark'
|
|
84
86
|
}
|
|
85
87
|
}
|
|
86
88
|
|
|
87
89
|
export class FullPanel extends Panel {
|
|
88
90
|
constructor(map) {
|
|
89
91
|
super(map)
|
|
90
|
-
this.
|
|
92
|
+
this.className = 'full dark'
|
|
91
93
|
this.mode = 'expanded'
|
|
92
94
|
}
|
|
93
95
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DomEvent, DomUtil } from '../../../vendors/leaflet/leaflet-src.esm.js'
|
|
2
2
|
import { translate } from '../i18n.js'
|
|
3
|
+
import { Positioned } from './base.js'
|
|
3
4
|
|
|
4
|
-
export default class Tooltip {
|
|
5
|
+
export default class Tooltip extends Positioned {
|
|
5
6
|
constructor(parent) {
|
|
7
|
+
super()
|
|
6
8
|
this.parent = parent
|
|
7
9
|
this.container = DomUtil.create('div', 'with-transition', this.parent)
|
|
8
10
|
this.container.id = 'umap-tooltip-container'
|
|
@@ -13,16 +15,8 @@ export default class Tooltip {
|
|
|
13
15
|
}
|
|
14
16
|
|
|
15
17
|
open(opts) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
this.anchorTop(opts.anchor)
|
|
19
|
-
} else if (opts.anchor && opts.position === 'left') {
|
|
20
|
-
this.anchorLeft(opts.anchor)
|
|
21
|
-
} else if (opts.anchor && opts.position === 'bottom') {
|
|
22
|
-
this.anchorBottom(opts.anchor)
|
|
23
|
-
} else {
|
|
24
|
-
this.anchorAbsolute()
|
|
25
|
-
}
|
|
18
|
+
const showIt = () => {
|
|
19
|
+
this.openAt(opts)
|
|
26
20
|
L.DomUtil.addClass(this.parent, 'umap-tooltip')
|
|
27
21
|
this.container.innerHTML = U.Utils.escapeHTML(opts.content)
|
|
28
22
|
}
|
|
@@ -34,48 +28,11 @@ export default class Tooltip {
|
|
|
34
28
|
if (opts.anchor) {
|
|
35
29
|
L.DomEvent.once(opts.anchor, 'mouseout', closeIt)
|
|
36
30
|
}
|
|
37
|
-
if (opts.duration !==
|
|
31
|
+
if (opts.duration !== Number.POSITIVE_INFINITY) {
|
|
38
32
|
window.setTimeout(closeIt, opts.duration || 3000)
|
|
39
33
|
}
|
|
40
34
|
}
|
|
41
35
|
|
|
42
|
-
anchorAbsolute() {
|
|
43
|
-
this.container.className = ''
|
|
44
|
-
const left =
|
|
45
|
-
this.parent.offsetLeft +
|
|
46
|
-
this.parent.clientWidth / 2 -
|
|
47
|
-
this.container.clientWidth / 2,
|
|
48
|
-
top = this.parent.offsetTop + 75
|
|
49
|
-
this.setPosition({ top: top, left: left })
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
anchorTop(el) {
|
|
53
|
-
this.container.className = 'tooltip-top'
|
|
54
|
-
const coords = this.getPosition(el)
|
|
55
|
-
this.setPosition({
|
|
56
|
-
left: coords.left - 10,
|
|
57
|
-
bottom: this.getDocHeight() - coords.top + 11,
|
|
58
|
-
})
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
anchorBottom(el) {
|
|
62
|
-
this.container.className = 'tooltip-bottom'
|
|
63
|
-
const coords = this.getPosition(el)
|
|
64
|
-
this.setPosition({
|
|
65
|
-
left: coords.left,
|
|
66
|
-
top: coords.bottom + 11,
|
|
67
|
-
})
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
anchorLeft(el) {
|
|
71
|
-
this.container.className = 'tooltip-left'
|
|
72
|
-
const coords = this.getPosition(el)
|
|
73
|
-
this.setPosition({
|
|
74
|
-
top: coords.top,
|
|
75
|
-
right: document.documentElement.offsetWidth - coords.left + 11,
|
|
76
|
-
})
|
|
77
|
-
}
|
|
78
|
-
|
|
79
36
|
close(id) {
|
|
80
37
|
// Clear timetout even if a new tooltip has been added
|
|
81
38
|
// in the meantime. Eg. after a mouseout from the anchor.
|
|
@@ -86,31 +43,4 @@ export default class Tooltip {
|
|
|
86
43
|
this.setPosition({})
|
|
87
44
|
L.DomUtil.removeClass(this.parent, 'umap-tooltip')
|
|
88
45
|
}
|
|
89
|
-
|
|
90
|
-
getPosition(el) {
|
|
91
|
-
return el.getBoundingClientRect()
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
setPosition(coords) {
|
|
95
|
-
if (coords.left) this.container.style.left = `${coords.left}px`
|
|
96
|
-
else this.container.style.left = 'initial'
|
|
97
|
-
if (coords.right) this.container.style.right = `${coords.right}px`
|
|
98
|
-
else this.container.style.right = 'initial'
|
|
99
|
-
if (coords.top) this.container.style.top = `${coords.top}px`
|
|
100
|
-
else this.container.style.top = 'initial'
|
|
101
|
-
if (coords.bottom) this.container.style.bottom = `${coords.bottom}px`
|
|
102
|
-
else this.container.style.bottom = 'initial'
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
getDocHeight() {
|
|
106
|
-
const D = document
|
|
107
|
-
return Math.max(
|
|
108
|
-
D.body.scrollHeight,
|
|
109
|
-
D.documentElement.scrollHeight,
|
|
110
|
-
D.body.offsetHeight,
|
|
111
|
-
D.documentElement.offsetHeight,
|
|
112
|
-
D.body.clientHeight,
|
|
113
|
-
D.documentElement.clientHeight
|
|
114
|
-
)
|
|
115
|
-
}
|
|
116
46
|
}
|
|
@@ -10,9 +10,8 @@ export default class URLs {
|
|
|
10
10
|
|
|
11
11
|
if (this.urls.hasOwnProperty(urlName)) {
|
|
12
12
|
return template(this.urls[urlName], params)
|
|
13
|
-
} else {
|
|
14
|
-
throw `Unable to find a URL for route ${urlName}`
|
|
15
13
|
}
|
|
14
|
+
throw `Unable to find a URL for route ${urlName}`
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
// Update if map_id is passed, create otherwise.
|
|
@@ -36,7 +36,7 @@ export function checkId(string) {
|
|
|
36
36
|
*/
|
|
37
37
|
export function getImpactsFromSchema(fields, schema) {
|
|
38
38
|
schema = schema || U.SCHEMA
|
|
39
|
-
|
|
39
|
+
const impacted = fields
|
|
40
40
|
.map((field) => {
|
|
41
41
|
// remove the option prefix for fields
|
|
42
42
|
// And only keep the first part in case of a subfield
|
|
@@ -63,9 +63,8 @@ export function getImpactsFromSchema(fields, schema) {
|
|
|
63
63
|
export default function getPurify() {
|
|
64
64
|
if (typeof window === 'undefined') {
|
|
65
65
|
return DOMPurifyInitializer(new global.JSDOM('').window)
|
|
66
|
-
} else {
|
|
67
|
-
return DOMPurifyInitializer(window)
|
|
68
66
|
}
|
|
67
|
+
return DOMPurifyInitializer(window)
|
|
69
68
|
}
|
|
70
69
|
|
|
71
70
|
export function escapeHTML(s) {
|
|
@@ -114,13 +113,13 @@ export function escapeHTML(s) {
|
|
|
114
113
|
|
|
115
114
|
export function toHTML(r, options) {
|
|
116
115
|
if (!r) return ''
|
|
117
|
-
const target =
|
|
116
|
+
const target = options?.target || 'blank'
|
|
118
117
|
|
|
119
118
|
// unordered lists
|
|
120
119
|
r = r.replace(/^\*\* (.*)/gm, '<ul><ul><li>$1</li></ul></ul>')
|
|
121
120
|
r = r.replace(/^\* (.*)/gm, '<ul><li>$1</li></ul>')
|
|
122
121
|
for (let ii = 0; ii < 3; ii++) {
|
|
123
|
-
r = r.replace(
|
|
122
|
+
r = r.replace(/<\/ul>(\r\n|\r|\n)<ul>/g, '')
|
|
124
123
|
}
|
|
125
124
|
|
|
126
125
|
// headings and hr
|
|
@@ -271,8 +270,8 @@ export function sortFeatures(features, sortKey, lang) {
|
|
|
271
270
|
const sortKeys = (sortKey || 'name').split(',')
|
|
272
271
|
|
|
273
272
|
const sort = (a, b, i) => {
|
|
274
|
-
let sortKey = sortKeys[i]
|
|
275
|
-
|
|
273
|
+
let sortKey = sortKeys[i]
|
|
274
|
+
let reverse = 1
|
|
276
275
|
if (sortKey[0] === '-') {
|
|
277
276
|
reverse = -1
|
|
278
277
|
sortKey = sortKey.substring(1)
|
|
@@ -315,19 +314,19 @@ export function getBaseUrl() {
|
|
|
315
314
|
}
|
|
316
315
|
|
|
317
316
|
export function hasVar(value) {
|
|
318
|
-
return typeof value === 'string' && value.indexOf('{')
|
|
317
|
+
return typeof value === 'string' && value.indexOf('{') !== -1
|
|
319
318
|
}
|
|
320
319
|
|
|
321
320
|
export function isPath(value) {
|
|
322
|
-
return value
|
|
321
|
+
return value?.length && value.startsWith('/')
|
|
323
322
|
}
|
|
324
323
|
|
|
325
324
|
export function isRemoteUrl(value) {
|
|
326
|
-
return value
|
|
325
|
+
return value?.length && value.startsWith('http')
|
|
327
326
|
}
|
|
328
327
|
|
|
329
328
|
export function isDataImage(value) {
|
|
330
|
-
return value
|
|
329
|
+
return value?.length && value.startsWith('data:image')
|
|
331
330
|
}
|
|
332
331
|
|
|
333
332
|
/**
|
|
@@ -349,15 +348,16 @@ export function normalize(s) {
|
|
|
349
348
|
|
|
350
349
|
// Vendorized from leaflet.utils
|
|
351
350
|
// https://github.com/Leaflet/Leaflet/blob/108c6717b70f57c63645498f9bd66b6677758786/src/core/Util.js#L132-L151
|
|
352
|
-
|
|
351
|
+
const templateRe = /\{ *([\w_ -]+) *\}/g
|
|
353
352
|
|
|
354
353
|
export function template(str, data) {
|
|
355
|
-
return str.replace(templateRe,
|
|
356
|
-
|
|
354
|
+
return str.replace(templateRe, (str, key) => {
|
|
355
|
+
let value = data[key]
|
|
357
356
|
|
|
358
357
|
if (value === undefined) {
|
|
359
|
-
throw new Error(
|
|
360
|
-
}
|
|
358
|
+
throw new Error(`No value provided for variable ${str}`)
|
|
359
|
+
}
|
|
360
|
+
if (typeof value === 'function') {
|
|
361
361
|
value = value(data)
|
|
362
362
|
}
|
|
363
363
|
return value
|
|
@@ -377,3 +377,23 @@ export function toggleBadge(element, value) {
|
|
|
377
377
|
if (value) element.dataset.badge = value === true ? ' ' : value
|
|
378
378
|
else delete element.dataset.badge
|
|
379
379
|
}
|
|
380
|
+
|
|
381
|
+
export function loadTemplate(html) {
|
|
382
|
+
const template = document.createElement('template')
|
|
383
|
+
template.innerHTML = html
|
|
384
|
+
.split('\n')
|
|
385
|
+
.map((line) => line.trim())
|
|
386
|
+
.join('')
|
|
387
|
+
return template.content.firstElementChild
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
export class WithTemplate {
|
|
391
|
+
loadTemplate(html) {
|
|
392
|
+
this.element = loadTemplate(html)
|
|
393
|
+
this.elements = {}
|
|
394
|
+
for (const element of this.element.querySelectorAll('[data-ref]')) {
|
|
395
|
+
this.elements[element.dataset.ref] = element
|
|
396
|
+
}
|
|
397
|
+
return this.element
|
|
398
|
+
}
|
|
399
|
+
}
|
|
@@ -162,7 +162,7 @@ U.BaseFeatureAction = L.ToolbarAction.extend({
|
|
|
162
162
|
this.postInit()
|
|
163
163
|
},
|
|
164
164
|
|
|
165
|
-
postInit:
|
|
165
|
+
postInit: () => {},
|
|
166
166
|
|
|
167
167
|
hideToolbar: function () {
|
|
168
168
|
this.map.removeLayer(this.toolbar)
|
|
@@ -356,7 +356,7 @@ U.DropControl = L.Class.extend({
|
|
|
356
356
|
this.dropzone.classList.add('umap-dragover')
|
|
357
357
|
},
|
|
358
358
|
|
|
359
|
-
dragover:
|
|
359
|
+
dragover: (e) => {
|
|
360
360
|
L.DomEvent.stop(e)
|
|
361
361
|
},
|
|
362
362
|
|
|
@@ -393,7 +393,7 @@ U.EditControl = L.Control.extend({
|
|
|
393
393
|
L.DomEvent.on(
|
|
394
394
|
enableEditing,
|
|
395
395
|
'mouseover',
|
|
396
|
-
|
|
396
|
+
() => {
|
|
397
397
|
map.tooltip.open({
|
|
398
398
|
content: map.help.displayLabel('TOGGLE_EDIT'),
|
|
399
399
|
anchor: enableEditing,
|
|
@@ -434,9 +434,9 @@ U.MoreControls = L.Control.extend({
|
|
|
434
434
|
},
|
|
435
435
|
|
|
436
436
|
toggle: function () {
|
|
437
|
-
const pos = this.getPosition()
|
|
438
|
-
|
|
439
|
-
|
|
437
|
+
const pos = this.getPosition()
|
|
438
|
+
const corner = this._map._controlCorners[pos]
|
|
439
|
+
const className = 'umap-more-controls'
|
|
440
440
|
if (L.DomUtil.hasClass(corner, className)) L.DomUtil.removeClass(corner, className)
|
|
441
441
|
else L.DomUtil.addClass(corner, className)
|
|
442
442
|
},
|
|
@@ -454,10 +454,10 @@ U.PermanentCreditsControl = L.Control.extend({
|
|
|
454
454
|
|
|
455
455
|
onAdd: function () {
|
|
456
456
|
const paragraphContainer = L.DomUtil.create(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
457
|
+
'div',
|
|
458
|
+
'umap-permanent-credits-container'
|
|
459
|
+
)
|
|
460
|
+
const creditsParagraph = L.DomUtil.create('p', '', paragraphContainer)
|
|
461
461
|
|
|
462
462
|
this.paragraphContainer = paragraphContainer
|
|
463
463
|
this.setCredits()
|
|
@@ -503,7 +503,7 @@ L.Control.Button = L.Control.extend({
|
|
|
503
503
|
return container
|
|
504
504
|
},
|
|
505
505
|
|
|
506
|
-
afterAdd:
|
|
506
|
+
afterAdd: (container) => {},
|
|
507
507
|
})
|
|
508
508
|
|
|
509
509
|
U.DataLayersControl = L.Control.Button.extend({
|
|
@@ -745,13 +745,13 @@ const ControlsMixin = {
|
|
|
745
745
|
L.DomUtil.createLink(
|
|
746
746
|
'umap-user',
|
|
747
747
|
rightContainer,
|
|
748
|
-
L._(
|
|
748
|
+
L._('My Dashboard ({username})', {
|
|
749
749
|
username: this.options.user.name,
|
|
750
750
|
}),
|
|
751
751
|
this.options.user.url
|
|
752
752
|
)
|
|
753
753
|
}
|
|
754
|
-
this.help.
|
|
754
|
+
this.help.getStartedLink(rightContainer)
|
|
755
755
|
const controlEditCancel = L.DomUtil.createButton(
|
|
756
756
|
'leaflet-control-edit-cancel',
|
|
757
757
|
rightContainer,
|
|
@@ -832,10 +832,10 @@ const ControlsMixin = {
|
|
|
832
832
|
row.dataset.id = L.stamp(datalayer)
|
|
833
833
|
})
|
|
834
834
|
const onReorder = (src, dst, initialIndex, finalIndex) => {
|
|
835
|
-
const layer = this.datalayers[src.dataset.id]
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
835
|
+
const layer = this.datalayers[src.dataset.id]
|
|
836
|
+
const other = this.datalayers[dst.dataset.id]
|
|
837
|
+
const minIndex = Math.min(layer.getRank(), other.getRank())
|
|
838
|
+
const maxIndex = Math.max(layer.getRank(), other.getRank())
|
|
839
839
|
if (finalIndex === 0) layer.bringToTop()
|
|
840
840
|
else if (finalIndex > initialIndex) layer.insertBefore(other)
|
|
841
841
|
else layer.insertAfter(other)
|
|
@@ -948,10 +948,10 @@ U.TileLayerChooser = L.Control.extend({
|
|
|
948
948
|
},
|
|
949
949
|
|
|
950
950
|
addTileLayerElement: function (tilelayer, options) {
|
|
951
|
-
const selectedClass = this.map.hasLayer(tilelayer) ? 'selected' : ''
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
951
|
+
const selectedClass = this.map.hasLayer(tilelayer) ? 'selected' : ''
|
|
952
|
+
const el = L.DomUtil.create('li', selectedClass, this._tilelayers_container)
|
|
953
|
+
const img = L.DomUtil.create('img', '', el)
|
|
954
|
+
const name = L.DomUtil.create('div', '', el)
|
|
955
955
|
img.src = U.Utils.template(tilelayer.options.url_template, this.map.demoTileInfos)
|
|
956
956
|
img.loading = 'lazy'
|
|
957
957
|
name.textContent = tilelayer.options.name
|
|
@@ -961,7 +961,7 @@ U.TileLayerChooser = L.Control.extend({
|
|
|
961
961
|
function () {
|
|
962
962
|
this.map.selectTileLayer(tilelayer)
|
|
963
963
|
this.map._controls.tilelayers.setLayers()
|
|
964
|
-
if (options
|
|
964
|
+
if (options?.callback) options.callback(tilelayer)
|
|
965
965
|
},
|
|
966
966
|
this
|
|
967
967
|
)
|
|
@@ -982,8 +982,8 @@ U.AttributionControl = L.Control.Attribution.extend({
|
|
|
982
982
|
this._container.innerHTML = ''
|
|
983
983
|
const container = L.DomUtil.create('div', 'attribution-container', this._container)
|
|
984
984
|
container.innerHTML = credits
|
|
985
|
-
const shortCredit = this._map.getOption('shortCredit')
|
|
986
|
-
|
|
985
|
+
const shortCredit = this._map.getOption('shortCredit')
|
|
986
|
+
const captionMenus = this._map.getOption('captionMenus')
|
|
987
987
|
if (shortCredit) {
|
|
988
988
|
L.DomUtil.element({
|
|
989
989
|
tagName: 'span',
|
|
@@ -1205,9 +1205,7 @@ L.Control.MiniMap.include({
|
|
|
1205
1205
|
this._miniMap.addLayer(this._layer)
|
|
1206
1206
|
},
|
|
1207
1207
|
|
|
1208
|
-
_cloneLayer:
|
|
1209
|
-
return new L.TileLayer(layer._url, L.Util.extend({}, layer.options))
|
|
1210
|
-
},
|
|
1208
|
+
_cloneLayer: (layer) => new L.TileLayer(layer._url, L.Util.extend({}, layer.options)),
|
|
1211
1209
|
})
|
|
1212
1210
|
|
|
1213
1211
|
L.Control.Loading.include({
|
|
@@ -1312,7 +1310,7 @@ U.Editable = L.Editable.extend({
|
|
|
1312
1310
|
},
|
|
1313
1311
|
|
|
1314
1312
|
drawingTooltip: function (e) {
|
|
1315
|
-
if (e.layer instanceof L.Marker && e.type
|
|
1313
|
+
if (e.layer instanceof L.Marker && e.type === 'editable:drawing:start') {
|
|
1316
1314
|
this.map.tooltip.open({ content: L._('Click to add a marker') })
|
|
1317
1315
|
}
|
|
1318
1316
|
if (!(e.layer instanceof L.Polyline)) {
|
|
@@ -1364,7 +1362,7 @@ U.Editable = L.Editable.extend({
|
|
|
1364
1362
|
this.map.ui.closeTooltip()
|
|
1365
1363
|
},
|
|
1366
1364
|
|
|
1367
|
-
onVertexRawClick:
|
|
1365
|
+
onVertexRawClick: (e) => {
|
|
1368
1366
|
e.layer.onVertexRawClick(e)
|
|
1369
1367
|
L.DomEvent.stop(e)
|
|
1370
1368
|
e.cancel()
|
umap/static/umap/js/umap.core.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
L.Util.copyToClipboard =
|
|
1
|
+
L.Util.copyToClipboard = (textToCopy) => {
|
|
2
2
|
// https://stackoverflow.com/a/65996386
|
|
3
3
|
// Navigator clipboard api needs a secure context (https)
|
|
4
4
|
if (navigator.clipboard && window.isSecureContext) {
|
|
@@ -25,10 +25,10 @@ L.Util.copyToClipboard = function (textToCopy) {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
L.Util.queryString =
|
|
28
|
+
L.Util.queryString = (name, fallback) => {
|
|
29
29
|
const decode = (s) => decodeURIComponent(s.replace(/\+/g, ' '))
|
|
30
|
-
const qs = window.location.search.slice(1).split('&')
|
|
31
|
-
|
|
30
|
+
const qs = window.location.search.slice(1).split('&')
|
|
31
|
+
const qa = {}
|
|
32
32
|
for (const i in qs) {
|
|
33
33
|
const key = qs[i].split('=')
|
|
34
34
|
if (!key) continue
|
|
@@ -37,27 +37,27 @@ L.Util.queryString = function (name, fallback) {
|
|
|
37
37
|
return qa[name] || fallback
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
L.Util.booleanFromQueryString =
|
|
40
|
+
L.Util.booleanFromQueryString = (name) => {
|
|
41
41
|
const value = L.Util.queryString(name)
|
|
42
42
|
return value === '1' || value === 'true'
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
L.Util.setFromQueryString =
|
|
45
|
+
L.Util.setFromQueryString = (options, name) => {
|
|
46
46
|
const value = L.Util.queryString(name)
|
|
47
47
|
if (typeof value !== 'undefined') options[name] = value
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
L.Util.setBooleanFromQueryString =
|
|
50
|
+
L.Util.setBooleanFromQueryString = (options, name) => {
|
|
51
51
|
const value = L.Util.queryString(name)
|
|
52
|
-
if (typeof value !== 'undefined') options[name] = value
|
|
52
|
+
if (typeof value !== 'undefined') options[name] = value === '1' || value === 'true'
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
L.Util.setNumberFromQueryString =
|
|
55
|
+
L.Util.setNumberFromQueryString = (options, name) => {
|
|
56
56
|
const value = +L.Util.queryString(name)
|
|
57
|
-
if (!isNaN(value)) options[name] = value
|
|
57
|
+
if (!Number.isNaN(value)) options[name] = value
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
L.Util.setNullableBooleanFromQueryString =
|
|
60
|
+
L.Util.setNullableBooleanFromQueryString = (options, name) => {
|
|
61
61
|
let value = L.Util.queryString(name)
|
|
62
62
|
if (typeof value !== 'undefined') {
|
|
63
63
|
if (value === 'null') value = null
|
|
@@ -192,7 +192,7 @@ L.DomUtil.after = (target, el) => {
|
|
|
192
192
|
// convert colour in range 0-255 to the modifier used within luminance calculation
|
|
193
193
|
L.DomUtil.colourMod = (colour) => {
|
|
194
194
|
const sRGB = colour / 255
|
|
195
|
-
let mod =
|
|
195
|
+
let mod = ((sRGB + 0.055) / 1.055) ** 2.4
|
|
196
196
|
if (sRGB < 0.03928) mod = sRGB / 12.92
|
|
197
197
|
return mod
|
|
198
198
|
}
|
|
@@ -222,7 +222,11 @@ L.DomUtil.contrastedColor = (el, bgcolor) => {
|
|
|
222
222
|
let rgb = window.getComputedStyle(el).getPropertyValue('background-color')
|
|
223
223
|
rgb = L.DomUtil.RGBRegex.exec(rgb)
|
|
224
224
|
if (!rgb || rgb.length !== 4) return out
|
|
225
|
-
rgb = [
|
|
225
|
+
rgb = [
|
|
226
|
+
Number.parseInt(rgb[1], 10),
|
|
227
|
+
Number.parseInt(rgb[2], 10),
|
|
228
|
+
Number.parseInt(rgb[3], 10),
|
|
229
|
+
]
|
|
226
230
|
out = L.DomUtil.contrastWCAG21(rgb)
|
|
227
231
|
if (bgcolor) _CACHE_CONSTRAST[bgcolor] = out
|
|
228
232
|
return out
|
|
@@ -247,9 +251,9 @@ L.DomEvent.once = (el, types, fn, context) => {
|
|
|
247
251
|
|
|
248
252
|
L.LatLng.prototype.isValid = function () {
|
|
249
253
|
return (
|
|
250
|
-
isFinite(this.lat) &&
|
|
254
|
+
Number.isFinite(this.lat) &&
|
|
251
255
|
Math.abs(this.lat) <= 90 &&
|
|
252
|
-
isFinite(this.lng) &&
|
|
256
|
+
Number.isFinite(this.lng) &&
|
|
253
257
|
Math.abs(this.lng) <= 180
|
|
254
258
|
)
|
|
255
259
|
}
|
|
@@ -7,15 +7,12 @@ U.DataLayerPermissions = L.Class.extend({
|
|
|
7
7
|
this.options = L.Util.setOptions(this, datalayer.options.permissions)
|
|
8
8
|
this.datalayer = datalayer
|
|
9
9
|
let isDirty = false
|
|
10
|
-
const self = this
|
|
11
10
|
try {
|
|
12
11
|
Object.defineProperty(this, 'isDirty', {
|
|
13
|
-
get:
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
set: function (status) {
|
|
12
|
+
get: () => isDirty,
|
|
13
|
+
set: (status) => {
|
|
17
14
|
isDirty = status
|
|
18
|
-
if (status)
|
|
15
|
+
if (status) this.datalayer.isDirty = status
|
|
19
16
|
},
|
|
20
17
|
})
|
|
21
18
|
} catch (e) {
|
|
@@ -29,19 +26,19 @@ U.DataLayerPermissions = L.Class.extend({
|
|
|
29
26
|
|
|
30
27
|
edit: function (container) {
|
|
31
28
|
const fields = [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
],
|
|
29
|
+
[
|
|
30
|
+
'options.edit_status',
|
|
31
|
+
{
|
|
32
|
+
handler: 'IntSelect',
|
|
33
|
+
label: L._('Who can edit "{layer}"', { layer: this.datalayer.getName() }),
|
|
34
|
+
selectOptions: this.datalayer.map.options.datalayer_edit_statuses,
|
|
35
|
+
},
|
|
40
36
|
],
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
]
|
|
38
|
+
const builder = new U.FormBuilder(this, fields, {
|
|
39
|
+
className: 'umap-form datalayer-permissions',
|
|
40
|
+
})
|
|
41
|
+
const form = builder.build()
|
|
45
42
|
container.appendChild(form)
|
|
46
43
|
},
|
|
47
44
|
|