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,12 +1,16 @@
|
|
|
1
1
|
U.FeatureMixin = {
|
|
2
2
|
staticOptions: { mainColor: 'color' },
|
|
3
3
|
|
|
4
|
+
getPreviewColor: function () {
|
|
5
|
+
return this.getDynamicOption(this.staticOptions.mainColor)
|
|
6
|
+
},
|
|
7
|
+
|
|
4
8
|
getSyncMetadata: function () {
|
|
5
9
|
return {
|
|
6
10
|
subject: 'feature',
|
|
7
11
|
metadata: {
|
|
8
12
|
id: this.id,
|
|
9
|
-
layerId: this.datalayer?.
|
|
13
|
+
layerId: this.datalayer?.umap_id || null,
|
|
10
14
|
featureType: this.getClassName(),
|
|
11
15
|
},
|
|
12
16
|
}
|
|
@@ -15,7 +19,18 @@ U.FeatureMixin = {
|
|
|
15
19
|
onCommit: function () {
|
|
16
20
|
// When the layer is a remote layer, we don't want to sync the creation of the
|
|
17
21
|
// points via the websocket, as the other peers will get them themselves.
|
|
18
|
-
if (this.datalayer
|
|
22
|
+
if (this.datalayer?.isRemoteLayer()) return
|
|
23
|
+
|
|
24
|
+
// The "endEdit" event is triggered at the end of an edition,
|
|
25
|
+
// and will trigger the sync.
|
|
26
|
+
// In the case of a deletion (or a change of layer), we don't want this
|
|
27
|
+
// event triggered to cause a sync event, as it would reintroduce
|
|
28
|
+
// deleted features.
|
|
29
|
+
// The `._marked_for_deletion` private property is here to track this status.
|
|
30
|
+
if (this._marked_for_deletion === true) {
|
|
31
|
+
this._marked_for_deletion = false
|
|
32
|
+
return
|
|
33
|
+
}
|
|
19
34
|
this.sync.upsert(this.toGeoJSON())
|
|
20
35
|
},
|
|
21
36
|
|
|
@@ -23,13 +38,10 @@ U.FeatureMixin = {
|
|
|
23
38
|
return this.toGeoJSON().geometry
|
|
24
39
|
},
|
|
25
40
|
|
|
26
|
-
syncDelete: function () {
|
|
27
|
-
this.sync.delete()
|
|
28
|
-
},
|
|
29
|
-
|
|
30
41
|
initialize: function (map, latlng, options, id) {
|
|
31
42
|
this.map = map
|
|
32
43
|
this.sync = map.sync_engine.proxy(this)
|
|
44
|
+
this._marked_for_deletion = false
|
|
33
45
|
|
|
34
46
|
if (typeof options === 'undefined') {
|
|
35
47
|
options = {}
|
|
@@ -58,19 +70,16 @@ U.FeatureMixin = {
|
|
|
58
70
|
}
|
|
59
71
|
}
|
|
60
72
|
let isDirty = false
|
|
61
|
-
const self = this
|
|
62
73
|
try {
|
|
63
74
|
Object.defineProperty(this, 'isDirty', {
|
|
64
|
-
get:
|
|
65
|
-
|
|
66
|
-
},
|
|
67
|
-
set: function (status) {
|
|
75
|
+
get: () => isDirty,
|
|
76
|
+
set: (status) => {
|
|
68
77
|
if (!isDirty && status) {
|
|
69
|
-
|
|
78
|
+
this.fire('isdirty')
|
|
70
79
|
}
|
|
71
80
|
isDirty = status
|
|
72
|
-
if (
|
|
73
|
-
|
|
81
|
+
if (this.datalayer) {
|
|
82
|
+
this.datalayer.isDirty = status
|
|
74
83
|
}
|
|
75
84
|
},
|
|
76
85
|
})
|
|
@@ -82,10 +91,10 @@ U.FeatureMixin = {
|
|
|
82
91
|
this.parentClass.prototype.initialize.call(this, latlng, options)
|
|
83
92
|
},
|
|
84
93
|
|
|
85
|
-
preInit:
|
|
94
|
+
preInit: () => {},
|
|
86
95
|
|
|
87
96
|
isReadOnly: function () {
|
|
88
|
-
return this.datalayer
|
|
97
|
+
return this.datalayer?.isDataReadOnly()
|
|
89
98
|
},
|
|
90
99
|
|
|
91
100
|
getSlug: function () {
|
|
@@ -189,16 +198,9 @@ U.FeatureMixin = {
|
|
|
189
198
|
},
|
|
190
199
|
|
|
191
200
|
getAdvancedEditActions: function (container) {
|
|
192
|
-
L.DomUtil.createButton(
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
L._('Delete'),
|
|
196
|
-
function (e) {
|
|
197
|
-
L.DomEvent.stop(e)
|
|
198
|
-
if (this.confirmDelete()) this.map.editPanel.close()
|
|
199
|
-
},
|
|
200
|
-
this
|
|
201
|
-
)
|
|
201
|
+
L.DomUtil.createButton('button umap-delete', container, L._('Delete'), (e) => {
|
|
202
|
+
this.confirmDelete().then(() => this.map.editPanel.close())
|
|
203
|
+
})
|
|
202
204
|
},
|
|
203
205
|
|
|
204
206
|
appendEditFieldsets: function (container) {
|
|
@@ -228,19 +230,17 @@ U.FeatureMixin = {
|
|
|
228
230
|
popupFieldset.appendChild(builder.build())
|
|
229
231
|
},
|
|
230
232
|
|
|
231
|
-
getInteractionOptions:
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
]
|
|
241
|
-
},
|
|
233
|
+
getInteractionOptions: () => [
|
|
234
|
+
'properties._umap_options.popupShape',
|
|
235
|
+
'properties._umap_options.popupTemplate',
|
|
236
|
+
'properties._umap_options.showLabel',
|
|
237
|
+
'properties._umap_options.labelDirection',
|
|
238
|
+
'properties._umap_options.labelInteractive',
|
|
239
|
+
'properties._umap_options.outlink',
|
|
240
|
+
'properties._umap_options.outlinkTarget',
|
|
241
|
+
],
|
|
242
242
|
|
|
243
|
-
endEdit:
|
|
243
|
+
endEdit: () => {},
|
|
244
244
|
|
|
245
245
|
getDisplayName: function (fallback) {
|
|
246
246
|
if (fallback === undefined) fallback = this.datalayer.options.name
|
|
@@ -269,21 +269,22 @@ U.FeatureMixin = {
|
|
|
269
269
|
this.bindPopup(new Class(this))
|
|
270
270
|
},
|
|
271
271
|
|
|
272
|
-
confirmDelete: function () {
|
|
273
|
-
|
|
272
|
+
confirmDelete: async function () {
|
|
273
|
+
const confirmed = await this.map.dialog.confirm(
|
|
274
|
+
L._('Are you sure you want to delete the feature?')
|
|
275
|
+
)
|
|
276
|
+
if (confirmed) {
|
|
274
277
|
this.del()
|
|
275
278
|
return true
|
|
276
279
|
}
|
|
277
280
|
return false
|
|
278
281
|
},
|
|
282
|
+
|
|
279
283
|
del: function (sync) {
|
|
280
284
|
this.isDirty = true
|
|
281
285
|
this.map.closePopup()
|
|
282
286
|
if (this.datalayer) {
|
|
283
|
-
this.datalayer.removeLayer(this)
|
|
284
|
-
this.disconnectFromDataLayer(this.datalayer)
|
|
285
|
-
|
|
286
|
-
if (sync !== false) this.syncDelete()
|
|
287
|
+
this.datalayer.removeLayer(this, sync)
|
|
287
288
|
}
|
|
288
289
|
},
|
|
289
290
|
|
|
@@ -298,7 +299,7 @@ U.FeatureMixin = {
|
|
|
298
299
|
}
|
|
299
300
|
},
|
|
300
301
|
|
|
301
|
-
cleanProperty:
|
|
302
|
+
cleanProperty: ([key, value]) => {
|
|
302
303
|
// dot in key will break the dot based property access
|
|
303
304
|
// while editing the feature
|
|
304
305
|
key = key.replace('.', '_')
|
|
@@ -326,7 +327,9 @@ U.FeatureMixin = {
|
|
|
326
327
|
this.datalayer.isDirty = true
|
|
327
328
|
this.datalayer.removeLayer(this)
|
|
328
329
|
}
|
|
330
|
+
|
|
329
331
|
datalayer.addLayer(this)
|
|
332
|
+
this.sync.upsert(this.toGeoJSON())
|
|
330
333
|
datalayer.isDirty = true
|
|
331
334
|
this._redraw()
|
|
332
335
|
},
|
|
@@ -411,7 +414,7 @@ U.FeatureMixin = {
|
|
|
411
414
|
},
|
|
412
415
|
|
|
413
416
|
_onClick: function (e) {
|
|
414
|
-
if (this.map.measureTools
|
|
417
|
+
if (this.map.measureTools?.enabled()) return
|
|
415
418
|
this._popupHandlersAdded = true // Prevent leaflet from managing event
|
|
416
419
|
if (!this.map.editEnabled) {
|
|
417
420
|
this.view(e)
|
|
@@ -434,13 +437,9 @@ U.FeatureMixin = {
|
|
|
434
437
|
L.DomEvent.stop(e)
|
|
435
438
|
},
|
|
436
439
|
|
|
437
|
-
getPopupToolbarAnchor:
|
|
438
|
-
return [0, 0]
|
|
439
|
-
},
|
|
440
|
+
getPopupToolbarAnchor: () => [0, 0],
|
|
440
441
|
|
|
441
|
-
getInplaceToolbarActions:
|
|
442
|
-
return [U.ToggleEditAction, U.DeleteFeatureAction]
|
|
443
|
-
},
|
|
442
|
+
getInplaceToolbarActions: (e) => [U.ToggleEditAction, U.DeleteFeatureAction],
|
|
444
443
|
|
|
445
444
|
_showContextMenu: function (e) {
|
|
446
445
|
L.DomEvent.stop(e)
|
|
@@ -463,7 +462,7 @@ U.FeatureMixin = {
|
|
|
463
462
|
if (permalink)
|
|
464
463
|
items.push({
|
|
465
464
|
text: L._('Permalink'),
|
|
466
|
-
callback:
|
|
465
|
+
callback: () => {
|
|
467
466
|
window.open(permalink)
|
|
468
467
|
},
|
|
469
468
|
})
|
|
@@ -477,7 +476,7 @@ U.FeatureMixin = {
|
|
|
477
476
|
let items = ['-']
|
|
478
477
|
if (this.map.editedFeature !== this) {
|
|
479
478
|
items.push({
|
|
480
|
-
text: L._('Edit this feature')
|
|
479
|
+
text: `${L._('Edit this feature')} (⇧+Click)`,
|
|
481
480
|
callback: this.edit,
|
|
482
481
|
context: this,
|
|
483
482
|
iconCls: 'umap-edit',
|
|
@@ -508,6 +507,7 @@ U.FeatureMixin = {
|
|
|
508
507
|
onRemove: function (map) {
|
|
509
508
|
this.parentClass.prototype.onRemove.call(this, map)
|
|
510
509
|
if (this.map.editedFeature === this) {
|
|
510
|
+
this._marked_for_deletion = true
|
|
511
511
|
this.endEdit()
|
|
512
512
|
this.map.editPanel.close()
|
|
513
513
|
}
|
|
@@ -546,7 +546,7 @@ U.FeatureMixin = {
|
|
|
546
546
|
}
|
|
547
547
|
keys = keys.split(',')
|
|
548
548
|
for (let i = 0, value; i < keys.length; i++) {
|
|
549
|
-
value =
|
|
549
|
+
value = `${this.properties[keys[i]] || ''}`
|
|
550
550
|
if (value.toLowerCase().indexOf(filter) !== -1) return true
|
|
551
551
|
}
|
|
552
552
|
return false
|
|
@@ -554,16 +554,16 @@ U.FeatureMixin = {
|
|
|
554
554
|
|
|
555
555
|
matchFacets: function () {
|
|
556
556
|
const selected = this.map.facets.selected
|
|
557
|
-
for (
|
|
557
|
+
for (const [name, { type, min, max, choices }] of Object.entries(selected)) {
|
|
558
558
|
let value = this.properties[name]
|
|
559
|
-
|
|
559
|
+
const parser = this.map.facets.getParser(type)
|
|
560
560
|
value = parser(value)
|
|
561
561
|
switch (type) {
|
|
562
562
|
case 'date':
|
|
563
563
|
case 'datetime':
|
|
564
564
|
case 'number':
|
|
565
|
-
if (!isNaN(min) && !isNaN(value) && min > value) return false
|
|
566
|
-
if (!isNaN(max) && !isNaN(value) && max < value) return false
|
|
565
|
+
if (!Number.isNaN(min) && !Number.isNaN(value) && min > value) return false
|
|
566
|
+
if (!Number.isNaN(max) && !Number.isNaN(value) && max < value) return false
|
|
567
567
|
break
|
|
568
568
|
default:
|
|
569
569
|
value = value || L._('<empty value>')
|
|
@@ -581,13 +581,9 @@ U.FeatureMixin = {
|
|
|
581
581
|
}).addTo(this.map, this, e.latlng, e.vertex)
|
|
582
582
|
},
|
|
583
583
|
|
|
584
|
-
getVertexActions:
|
|
585
|
-
return [U.DeleteVertexAction]
|
|
586
|
-
},
|
|
584
|
+
getVertexActions: () => [U.DeleteVertexAction],
|
|
587
585
|
|
|
588
|
-
isMulti:
|
|
589
|
-
return false
|
|
590
|
-
},
|
|
586
|
+
isMulti: () => false,
|
|
591
587
|
|
|
592
588
|
clone: function () {
|
|
593
589
|
const geoJSON = this.toGeoJSON()
|
|
@@ -663,11 +659,7 @@ U.Marker = L.Marker.extend({
|
|
|
663
659
|
},
|
|
664
660
|
|
|
665
661
|
_onMouseOut: function () {
|
|
666
|
-
if (
|
|
667
|
-
this.dragging &&
|
|
668
|
-
this.dragging._draggable &&
|
|
669
|
-
!this.dragging._draggable._moving
|
|
670
|
-
) {
|
|
662
|
+
if (this.dragging?._draggable && !this.dragging._draggable._moving) {
|
|
671
663
|
// Do not disable if the mouse went out while dragging
|
|
672
664
|
this._disableDragging()
|
|
673
665
|
}
|
|
@@ -688,14 +680,14 @@ U.Marker = L.Marker.extend({
|
|
|
688
680
|
|
|
689
681
|
_disableDragging: function () {
|
|
690
682
|
if (this.map.editEnabled) {
|
|
691
|
-
if (this.editor
|
|
683
|
+
if (this.editor?.drawing) return // when creating a new marker, the mouse can trigger the mouseover/mouseout event
|
|
692
684
|
// do not listen to them
|
|
693
685
|
this.disableEdit()
|
|
694
686
|
}
|
|
695
687
|
},
|
|
696
688
|
|
|
697
689
|
_redraw: function () {
|
|
698
|
-
if (this.datalayer
|
|
690
|
+
if (this.datalayer?.isVisible()) {
|
|
699
691
|
this._initIcon()
|
|
700
692
|
this.update()
|
|
701
693
|
}
|
|
@@ -710,8 +702,8 @@ U.Marker = L.Marker.extend({
|
|
|
710
702
|
},
|
|
711
703
|
|
|
712
704
|
_getTooltipAnchor: function () {
|
|
713
|
-
const anchor = this.options.icon.options.tooltipAnchor.clone()
|
|
714
|
-
|
|
705
|
+
const anchor = this.options.icon.options.tooltipAnchor.clone()
|
|
706
|
+
const direction = this.getOption('labelDirection')
|
|
715
707
|
if (direction === 'left') {
|
|
716
708
|
anchor.x *= -1
|
|
717
709
|
} else if (direction === 'bottom') {
|
|
@@ -746,22 +738,16 @@ U.Marker = L.Marker.extend({
|
|
|
746
738
|
return this._latlng
|
|
747
739
|
},
|
|
748
740
|
|
|
749
|
-
getClassName:
|
|
750
|
-
return 'marker'
|
|
751
|
-
},
|
|
741
|
+
getClassName: () => 'marker',
|
|
752
742
|
|
|
753
|
-
getShapeOptions:
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
]
|
|
760
|
-
},
|
|
743
|
+
getShapeOptions: () => [
|
|
744
|
+
'properties._umap_options.color',
|
|
745
|
+
'properties._umap_options.iconClass',
|
|
746
|
+
'properties._umap_options.iconUrl',
|
|
747
|
+
'properties._umap_options.iconOpacity',
|
|
748
|
+
],
|
|
761
749
|
|
|
762
|
-
getAdvancedOptions:
|
|
763
|
-
return ['properties._umap_options.zoomTo']
|
|
764
|
-
},
|
|
750
|
+
getAdvancedOptions: () => ['properties._umap_options.zoomTo'],
|
|
765
751
|
|
|
766
752
|
appendEditFieldsets: function (container) {
|
|
767
753
|
U.FeatureMixin.appendEditFieldsets.call(this, container)
|
|
@@ -773,8 +759,8 @@ U.Marker = L.Marker.extend({
|
|
|
773
759
|
callback: function () {
|
|
774
760
|
if (!this._latlng.isValid()) {
|
|
775
761
|
U.Alert.error(L._('Invalid latitude or longitude'))
|
|
776
|
-
builder.
|
|
777
|
-
builder.
|
|
762
|
+
builder.restoreField('_latlng.lat')
|
|
763
|
+
builder.restoreField('_latlng.lng')
|
|
778
764
|
}
|
|
779
765
|
this.zoomTo({ easing: false })
|
|
780
766
|
},
|
|
@@ -847,21 +833,17 @@ U.PathMixin = {
|
|
|
847
833
|
'interactive',
|
|
848
834
|
],
|
|
849
835
|
|
|
850
|
-
getShapeOptions:
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
]
|
|
856
|
-
},
|
|
836
|
+
getShapeOptions: () => [
|
|
837
|
+
'properties._umap_options.color',
|
|
838
|
+
'properties._umap_options.opacity',
|
|
839
|
+
'properties._umap_options.weight',
|
|
840
|
+
],
|
|
857
841
|
|
|
858
|
-
getAdvancedOptions:
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
]
|
|
864
|
-
},
|
|
842
|
+
getAdvancedOptions: () => [
|
|
843
|
+
'properties._umap_options.smoothFactor',
|
|
844
|
+
'properties._umap_options.dashArray',
|
|
845
|
+
'properties._umap_options.zoomTo',
|
|
846
|
+
],
|
|
865
847
|
|
|
866
848
|
setStyle: function (options) {
|
|
867
849
|
options = options || {}
|
|
@@ -876,7 +858,7 @@ U.PathMixin = {
|
|
|
876
858
|
},
|
|
877
859
|
|
|
878
860
|
_redraw: function () {
|
|
879
|
-
if (this.datalayer
|
|
861
|
+
if (this.datalayer?.isVisible()) {
|
|
880
862
|
this.setStyle()
|
|
881
863
|
this.resetTooltip()
|
|
882
864
|
}
|
|
@@ -890,14 +872,14 @@ U.PathMixin = {
|
|
|
890
872
|
// this.map.on('showmeasure', this.showMeasureTooltip, this);
|
|
891
873
|
// this.map.on('hidemeasure', this.removeTooltip, this);
|
|
892
874
|
this.parentClass.prototype.onAdd.call(this, map)
|
|
893
|
-
if (this.editing
|
|
875
|
+
if (this.editing?.enabled()) this.editing.addHooks()
|
|
894
876
|
this.resetTooltip()
|
|
895
877
|
},
|
|
896
878
|
|
|
897
879
|
onRemove: function (map) {
|
|
898
880
|
// this.map.off('showmeasure', this.showMeasureTooltip, this);
|
|
899
881
|
// this.map.off('hidemeasure', this.removeTooltip, this);
|
|
900
|
-
if (this.editing
|
|
882
|
+
if (this.editing?.enabled()) this.editing.removeHooks()
|
|
901
883
|
U.FeatureMixin.onRemove.call(this, map)
|
|
902
884
|
},
|
|
903
885
|
|
|
@@ -919,7 +901,7 @@ U.PathMixin = {
|
|
|
919
901
|
},
|
|
920
902
|
|
|
921
903
|
_onMouseOver: function () {
|
|
922
|
-
if (this.map.measureTools
|
|
904
|
+
if (this.map.measureTools?.enabled()) {
|
|
923
905
|
this.map.tooltip.open({ content: this.getMeasure(), anchor: this })
|
|
924
906
|
} else if (this.map.editEnabled && !this.map.editedFeature) {
|
|
925
907
|
this.map.tooltip.open({ content: L._('Click to edit'), anchor: this })
|
|
@@ -1070,13 +1052,9 @@ U.Polyline = L.Polyline.extend({
|
|
|
1070
1052
|
mainColor: 'color',
|
|
1071
1053
|
},
|
|
1072
1054
|
|
|
1073
|
-
isSameClass:
|
|
1074
|
-
return other instanceof U.Polyline
|
|
1075
|
-
},
|
|
1055
|
+
isSameClass: (other) => other instanceof U.Polyline,
|
|
1076
1056
|
|
|
1077
|
-
getClassName:
|
|
1078
|
-
return 'polyline'
|
|
1079
|
-
},
|
|
1057
|
+
getClassName: () => 'polyline',
|
|
1080
1058
|
|
|
1081
1059
|
getMeasure: function (shape) {
|
|
1082
1060
|
const length = L.GeoUtil.lineLength(this.map, shape || this._defaultShape())
|
|
@@ -1169,11 +1147,11 @@ U.Polyline = L.Polyline.extend({
|
|
|
1169
1147
|
from.reverse()
|
|
1170
1148
|
toMerge = [from, to]
|
|
1171
1149
|
}
|
|
1172
|
-
const a = toMerge[0]
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1150
|
+
const a = toMerge[0]
|
|
1151
|
+
const b = toMerge[1]
|
|
1152
|
+
const p1 = this.map.latLngToContainerPoint(a[a.length - 1])
|
|
1153
|
+
const p2 = this.map.latLngToContainerPoint(b[0])
|
|
1154
|
+
const tolerance = 5 // px on screen
|
|
1177
1155
|
if (Math.abs(p1.x - p2.x) <= tolerance && Math.abs(p1.y - p2.y) <= tolerance) {
|
|
1178
1156
|
a.pop()
|
|
1179
1157
|
}
|
|
@@ -1198,8 +1176,8 @@ U.Polyline = L.Polyline.extend({
|
|
|
1198
1176
|
},
|
|
1199
1177
|
|
|
1200
1178
|
getVertexActions: function (e) {
|
|
1201
|
-
const actions = U.FeatureMixin.getVertexActions.call(this, e)
|
|
1202
|
-
|
|
1179
|
+
const actions = U.FeatureMixin.getVertexActions.call(this, e)
|
|
1180
|
+
const index = e.vertex.getIndex()
|
|
1203
1181
|
if (index === 0 || index === e.vertex.getLastIndex())
|
|
1204
1182
|
actions.push(U.ContinueLineAction)
|
|
1205
1183
|
else actions.push(U.SplitLineAction)
|
|
@@ -1214,15 +1192,11 @@ U.Polygon = L.Polygon.extend({
|
|
|
1214
1192
|
mainColor: 'fillColor',
|
|
1215
1193
|
},
|
|
1216
1194
|
|
|
1217
|
-
isSameClass:
|
|
1218
|
-
return other instanceof U.Polygon
|
|
1219
|
-
},
|
|
1195
|
+
isSameClass: (other) => other instanceof U.Polygon,
|
|
1220
1196
|
|
|
1221
|
-
getClassName:
|
|
1222
|
-
return 'polygon'
|
|
1223
|
-
},
|
|
1197
|
+
getClassName: () => 'polygon',
|
|
1224
1198
|
|
|
1225
|
-
getShapeOptions:
|
|
1199
|
+
getShapeOptions: () => {
|
|
1226
1200
|
const options = U.PathMixin.getShapeOptions()
|
|
1227
1201
|
options.push(
|
|
1228
1202
|
'properties._umap_options.stroke',
|
|
@@ -1233,7 +1207,15 @@ U.Polygon = L.Polygon.extend({
|
|
|
1233
1207
|
return options
|
|
1234
1208
|
},
|
|
1235
1209
|
|
|
1236
|
-
|
|
1210
|
+
getPreviewColor: function () {
|
|
1211
|
+
// If user set a fillColor, use it, otherwise default to color
|
|
1212
|
+
// which is usually the only one set
|
|
1213
|
+
const color = this.getDynamicOption(this.staticOptions.mainColor)
|
|
1214
|
+
if (color && color !== U.SCHEMA.color.default) return color
|
|
1215
|
+
return this.getDynamicOption('color')
|
|
1216
|
+
},
|
|
1217
|
+
|
|
1218
|
+
getInteractionOptions: () => {
|
|
1237
1219
|
const options = U.FeatureMixin.getInteractionOptions()
|
|
1238
1220
|
options.push('properties._umap_options.interactive')
|
|
1239
1221
|
return options
|
|
@@ -1245,8 +1227,8 @@ U.Polygon = L.Polygon.extend({
|
|
|
1245
1227
|
},
|
|
1246
1228
|
|
|
1247
1229
|
getContextMenuEditItems: function (e) {
|
|
1248
|
-
const items = U.PathMixin.getContextMenuEditItems.call(this, e)
|
|
1249
|
-
|
|
1230
|
+
const items = U.PathMixin.getContextMenuEditItems.call(this, e)
|
|
1231
|
+
const shape = this.shapeAt(e.latlng)
|
|
1250
1232
|
// No multi and no holes.
|
|
1251
1233
|
if (shape && !this.isMulti() && (L.LineUtil.isFlat(shape) || shape.length === 1)) {
|
|
1252
1234
|
items.push({
|