umap-project 2.8.0a1__py3-none-any.whl → 2.8.0b0__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.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/locale/en/LC_MESSAGES/django.po +13 -13
- umap/management/commands/empty_trash.py +5 -2
- umap/settings/local_s3.py +45 -0
- umap/static/umap/css/form.css +3 -0
- umap/static/umap/js/modules/data/features.js +12 -0
- umap/static/umap/js/modules/data/layer.js +37 -18
- umap/static/umap/js/modules/importer.js +65 -20
- umap/static/umap/js/modules/rendering/icon.js +2 -1
- umap/static/umap/js/modules/rendering/map.js +7 -7
- umap/static/umap/js/modules/rendering/ui.js +6 -2
- umap/static/umap/js/modules/request.js +2 -2
- umap/static/umap/js/modules/ui/dialog.js +5 -0
- umap/static/umap/js/modules/umap.js +32 -9
- umap/static/umap/js/umap.controls.js +7 -4
- umap/static/umap/js/umap.forms.js +44 -0
- umap/static/umap/locale/en.js +3 -1
- umap/static/umap/locale/en.json +3 -1
- umap/static/umap/locale/fr.js +3 -1
- umap/static/umap/locale/fr.json +3 -1
- umap/static/umap/map.css +34 -166
- umap/static/umap/vars.css +0 -1
- umap/templates/base.html +2 -0
- umap/templates/umap/components/alerts/alert.html +4 -0
- umap/templates/umap/css.html +3 -0
- umap/templates/umap/js.html +2 -0
- umap/templates/umap/map_init.html +2 -0
- umap/templates/umap/user_dashboard.html +2 -0
- umap/tests/fixtures/test_upload_simple_marker.json +19 -0
- umap/tests/integration/test_edit_datalayer.py +11 -0
- umap/tests/integration/test_import.py +20 -1
- umap/tests/test_dashboard.py +82 -0
- umap/tests/test_team_views.py +35 -1
- umap/tests/test_views.py +0 -74
- umap/views.py +20 -15
- {umap_project-2.8.0a1.dist-info → umap_project-2.8.0b0.dist-info}/METADATA +1 -1
- {umap_project-2.8.0a1.dist-info → umap_project-2.8.0b0.dist-info}/RECORD +40 -37
- {umap_project-2.8.0a1.dist-info → umap_project-2.8.0b0.dist-info}/WHEEL +0 -0
- {umap_project-2.8.0a1.dist-info → umap_project-2.8.0b0.dist-info}/entry_points.txt +0 -0
- {umap_project-2.8.0a1.dist-info → umap_project-2.8.0b0.dist-info}/licenses/LICENSE +0 -0
umap/__init__.py
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
VERSION = "2.8.
|
|
1
|
+
VERSION = "2.8.0b0"
|
|
@@ -8,7 +8,7 @@ msgid ""
|
|
|
8
8
|
msgstr ""
|
|
9
9
|
"Project-Id-Version: PACKAGE VERSION\n"
|
|
10
10
|
"Report-Msgid-Bugs-To: \n"
|
|
11
|
-
"POT-Creation-Date: 2024-12-
|
|
11
|
+
"POT-Creation-Date: 2024-12-13 08:26+0000\n"
|
|
12
12
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
|
13
13
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
|
14
14
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
|
@@ -617,57 +617,57 @@ msgstr ""
|
|
|
617
617
|
msgid "View the map"
|
|
618
618
|
msgstr ""
|
|
619
619
|
|
|
620
|
-
#: views.py:
|
|
620
|
+
#: views.py:821
|
|
621
621
|
msgid "See full screen"
|
|
622
622
|
msgstr ""
|
|
623
623
|
|
|
624
|
-
#: views.py:
|
|
624
|
+
#: views.py:964
|
|
625
625
|
msgid "Map editors updated with success!"
|
|
626
626
|
msgstr ""
|
|
627
627
|
|
|
628
|
-
#: views.py:
|
|
628
|
+
#: views.py:1000
|
|
629
629
|
#, python-format
|
|
630
630
|
msgid "The uMap edit link for your map: %(map_name)s"
|
|
631
631
|
msgstr ""
|
|
632
632
|
|
|
633
|
-
#: views.py:
|
|
633
|
+
#: views.py:1003
|
|
634
634
|
#, python-format
|
|
635
635
|
msgid "Here is your secret edit link: %(link)s"
|
|
636
636
|
msgstr ""
|
|
637
637
|
|
|
638
|
-
#: views.py:
|
|
638
|
+
#: views.py:1010
|
|
639
639
|
#, python-format
|
|
640
640
|
msgid "Can't send email to %(email)s"
|
|
641
641
|
msgstr ""
|
|
642
642
|
|
|
643
|
-
#: views.py:
|
|
643
|
+
#: views.py:1013
|
|
644
644
|
#, python-format
|
|
645
645
|
msgid "Email sent to %(email)s"
|
|
646
646
|
msgstr ""
|
|
647
647
|
|
|
648
|
-
#: views.py:
|
|
648
|
+
#: views.py:1024
|
|
649
649
|
msgid "Only its owner can delete the map."
|
|
650
650
|
msgstr ""
|
|
651
651
|
|
|
652
|
-
#: views.py:
|
|
652
|
+
#: views.py:1027
|
|
653
653
|
msgid "Map successfully deleted."
|
|
654
654
|
msgstr ""
|
|
655
655
|
|
|
656
|
-
#: views.py:
|
|
656
|
+
#: views.py:1053
|
|
657
657
|
#, python-format
|
|
658
658
|
msgid ""
|
|
659
659
|
"Your map has been cloned! If you want to edit this map from another "
|
|
660
660
|
"computer, please use this link: %(anonymous_url)s"
|
|
661
661
|
msgstr ""
|
|
662
662
|
|
|
663
|
-
#: views.py:
|
|
663
|
+
#: views.py:1058
|
|
664
664
|
msgid "Congratulations, your map has been cloned!"
|
|
665
665
|
msgstr ""
|
|
666
666
|
|
|
667
|
-
#: views.py:
|
|
667
|
+
#: views.py:1309
|
|
668
668
|
msgid "Layer successfully deleted."
|
|
669
669
|
msgstr ""
|
|
670
670
|
|
|
671
|
-
#: views.py:
|
|
671
|
+
#: views.py:1331
|
|
672
672
|
msgid "Permissions updated with success!"
|
|
673
673
|
msgstr ""
|
|
@@ -23,10 +23,13 @@ class Command(BaseCommand):
|
|
|
23
23
|
|
|
24
24
|
def handle(self, *args, **options):
|
|
25
25
|
days = options["days"]
|
|
26
|
-
since = datetime.utcnow() - timedelta(days=days)
|
|
26
|
+
since = (datetime.utcnow() - timedelta(days=days)).date()
|
|
27
27
|
print(f"Deleting map in trash since {since}")
|
|
28
28
|
maps = Map.objects.filter(share_status=Map.DELETED, modified_at__lt=since)
|
|
29
29
|
for map in maps:
|
|
30
|
+
map_id = map.id
|
|
31
|
+
map_name = map.name
|
|
32
|
+
trashed_at = map.modified_at.date()
|
|
30
33
|
if not options["dry_run"]:
|
|
31
34
|
map.delete()
|
|
32
|
-
print(f"Deleted map {
|
|
35
|
+
print(f"Deleted map {map_name} ({map_id}), trashed at {trashed_at}")
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from umap.settings.local import *
|
|
2
|
+
|
|
3
|
+
DATABASES = {
|
|
4
|
+
"default": {
|
|
5
|
+
"ENGINE": "django.contrib.gis.db.backends.postgis",
|
|
6
|
+
"NAME": "umaps3",
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
STORAGES = {
|
|
11
|
+
"default": {
|
|
12
|
+
"BACKEND": "storages.backends.s3.S3Storage",
|
|
13
|
+
"OPTIONS": {
|
|
14
|
+
"access_key": "OScTD3CClCcO54Ax2DLz",
|
|
15
|
+
"secret_key": "eK9tfPRHoFh0nKLkZpJJoC4RJS1ptGfko3iBBd5k",
|
|
16
|
+
"bucket_name": "umap-default",
|
|
17
|
+
"region_name": "eu",
|
|
18
|
+
"endpoint_url": "http://127.0.0.1:9000",
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
"data": {
|
|
22
|
+
"BACKEND": "umap.storage.s3.S3DataStorage",
|
|
23
|
+
"OPTIONS": {
|
|
24
|
+
"access_key": "OScTD3CClCcO54Ax2DLz",
|
|
25
|
+
"secret_key": "eK9tfPRHoFh0nKLkZpJJoC4RJS1ptGfko3iBBd5k",
|
|
26
|
+
"bucket_name": "umap",
|
|
27
|
+
"region_name": "eu",
|
|
28
|
+
"endpoint_url": "http://127.0.0.1:9000",
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
"staticfiles": {
|
|
32
|
+
"BACKEND": "storages.backends.s3.S3Storage",
|
|
33
|
+
"OPTIONS": {
|
|
34
|
+
"access_key": "OScTD3CClCcO54Ax2DLz",
|
|
35
|
+
"secret_key": "eK9tfPRHoFh0nKLkZpJJoC4RJS1ptGfko3iBBd5k",
|
|
36
|
+
"bucket_name": "umap-staticfiles",
|
|
37
|
+
"region_name": "eu",
|
|
38
|
+
"endpoint_url": "http://127.0.0.1:9000",
|
|
39
|
+
"default_acl": "public-read",
|
|
40
|
+
# "querystring_auth": False,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
# STATIC_URL = "http://127.0.0.1:9000/umap-staticfiles/"
|
umap/static/umap/css/form.css
CHANGED
|
@@ -658,6 +658,18 @@ class Feature {
|
|
|
658
658
|
)
|
|
659
659
|
return items
|
|
660
660
|
}
|
|
661
|
+
|
|
662
|
+
isActive() {
|
|
663
|
+
return this._umap.activeFeature === this
|
|
664
|
+
}
|
|
665
|
+
|
|
666
|
+
activate() {
|
|
667
|
+
this._umap.activeFeature = this
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
deactivate() {
|
|
671
|
+
if (this._umap.activeFeature === this) this._umap.activeFeature = undefined
|
|
672
|
+
}
|
|
661
673
|
}
|
|
662
674
|
|
|
663
675
|
export class Point extends Feature {
|
|
@@ -252,10 +252,11 @@ export class DataLayer extends ServerStored {
|
|
|
252
252
|
}
|
|
253
253
|
|
|
254
254
|
fromGeoJSON(geojson, sync = true) {
|
|
255
|
-
this.addData(geojson, sync)
|
|
255
|
+
const features = this.addData(geojson, sync)
|
|
256
256
|
this._geojson = geojson
|
|
257
257
|
this.onDataLoaded()
|
|
258
258
|
this.dataChanged()
|
|
259
|
+
return features
|
|
259
260
|
}
|
|
260
261
|
|
|
261
262
|
onDataLoaded() {
|
|
@@ -315,7 +316,7 @@ export class DataLayer extends ServerStored {
|
|
|
315
316
|
const response = await this._umap.request.get(url)
|
|
316
317
|
if (response?.ok) {
|
|
317
318
|
this.clear()
|
|
318
|
-
this._umap.formatter
|
|
319
|
+
return this._umap.formatter
|
|
319
320
|
.parse(await response.text(), this.options.remoteData.format)
|
|
320
321
|
.then((geojson) => this.fromGeoJSON(geojson))
|
|
321
322
|
}
|
|
@@ -443,10 +444,11 @@ export class DataLayer extends ServerStored {
|
|
|
443
444
|
try {
|
|
444
445
|
// Do not fail if remote data is somehow invalid,
|
|
445
446
|
// otherwise the layer becomes uneditable.
|
|
446
|
-
this.makeFeatures(geojson, sync)
|
|
447
|
+
return this.makeFeatures(geojson, sync)
|
|
447
448
|
} catch (err) {
|
|
448
449
|
console.log('Error with DataLayer', this.id)
|
|
449
450
|
console.error(err)
|
|
451
|
+
return []
|
|
450
452
|
}
|
|
451
453
|
}
|
|
452
454
|
|
|
@@ -463,10 +465,13 @@ export class DataLayer extends ServerStored {
|
|
|
463
465
|
? geojson
|
|
464
466
|
: geojson.features || geojson.geometries
|
|
465
467
|
if (!collection) return
|
|
468
|
+
const features = []
|
|
466
469
|
this.sortFeatures(collection)
|
|
467
|
-
for (const
|
|
468
|
-
this.makeFeature(
|
|
470
|
+
for (const featureJson of collection) {
|
|
471
|
+
const feature = this.makeFeature(featureJson, sync)
|
|
472
|
+
if (feature) features.push(feature)
|
|
469
473
|
}
|
|
474
|
+
return features
|
|
470
475
|
}
|
|
471
476
|
|
|
472
477
|
makeFeature(geojson = {}, sync = true, id = null) {
|
|
@@ -503,31 +508,45 @@ export class DataLayer extends ServerStored {
|
|
|
503
508
|
}
|
|
504
509
|
|
|
505
510
|
async importRaw(raw, format) {
|
|
506
|
-
this._umap.formatter
|
|
511
|
+
return this._umap.formatter
|
|
507
512
|
.parse(raw, format)
|
|
508
513
|
.then((geojson) => this.addData(geojson))
|
|
509
|
-
.then(() =>
|
|
510
|
-
|
|
514
|
+
.then((data) => {
|
|
515
|
+
if (data?.length) this.isDirty = true
|
|
516
|
+
return data
|
|
517
|
+
})
|
|
511
518
|
}
|
|
512
519
|
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
520
|
+
readFile(f) {
|
|
521
|
+
return new Promise((resolve) => {
|
|
522
|
+
const reader = new FileReader()
|
|
523
|
+
reader.onloadend = () => resolve(reader.result)
|
|
524
|
+
reader.readAsText(f)
|
|
525
|
+
})
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
async importFromFiles(files, type) {
|
|
529
|
+
const toLoad = []
|
|
530
|
+
for (const file of files) {
|
|
531
|
+
toLoad.push(this.importFromFile(file, type))
|
|
516
532
|
}
|
|
533
|
+
const features = await Promise.all(toLoad)
|
|
534
|
+
return new Promise((resolve) => {
|
|
535
|
+
resolve([].concat(...features))
|
|
536
|
+
})
|
|
517
537
|
}
|
|
518
538
|
|
|
519
|
-
importFromFile(
|
|
520
|
-
const reader = new FileReader()
|
|
539
|
+
async importFromFile(file, type) {
|
|
521
540
|
type = type || Utils.detectFileType(f)
|
|
522
|
-
|
|
523
|
-
|
|
541
|
+
const raw = await this.readFile(file)
|
|
542
|
+
return this.importRaw(raw, type)
|
|
524
543
|
}
|
|
525
544
|
|
|
526
545
|
async importFromUrl(uri, type) {
|
|
527
546
|
uri = this._umap.renderUrl(uri)
|
|
528
547
|
const response = await this._umap.request.get(uri)
|
|
529
548
|
if (response?.ok) {
|
|
530
|
-
this.importRaw(await response.text(), type)
|
|
549
|
+
return this.importRaw(await response.text(), type)
|
|
531
550
|
}
|
|
532
551
|
}
|
|
533
552
|
|
|
@@ -930,9 +949,9 @@ export class DataLayer extends ServerStored {
|
|
|
930
949
|
else this.hide()
|
|
931
950
|
}
|
|
932
951
|
|
|
933
|
-
zoomTo() {
|
|
952
|
+
zoomTo(bounds) {
|
|
934
953
|
if (!this.isVisible()) return
|
|
935
|
-
|
|
954
|
+
bounds = bounds || this.layer.getBounds()
|
|
936
955
|
if (bounds.isValid()) {
|
|
937
956
|
const options = { maxZoom: this.getOption('zoomTo') }
|
|
938
957
|
this._leafletMap.fitBounds(bounds, options)
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
DomEvent,
|
|
3
|
+
DomUtil,
|
|
4
|
+
LatLngBounds,
|
|
5
|
+
} from '../../vendors/leaflet/leaflet-src.esm.js'
|
|
2
6
|
import { uMapAlert as Alert } from '../components/alerts/alert.js'
|
|
3
7
|
import { translate } from './i18n.js'
|
|
4
8
|
import { SCHEMA } from './schema.js'
|
|
@@ -60,7 +64,10 @@ export default class Importer extends Utils.WithTemplate {
|
|
|
60
64
|
this.TYPES = ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap']
|
|
61
65
|
this.IMPORTERS = []
|
|
62
66
|
this.loadImporters()
|
|
63
|
-
this.dialog = new Dialog({
|
|
67
|
+
this.dialog = new Dialog({
|
|
68
|
+
className: 'importers dark',
|
|
69
|
+
back: () => this.showImporters(),
|
|
70
|
+
})
|
|
64
71
|
}
|
|
65
72
|
|
|
66
73
|
loadImporters() {
|
|
@@ -168,7 +175,7 @@ export default class Importer extends Utils.WithTemplate {
|
|
|
168
175
|
button.addEventListener('click', () => plugin.open(this))
|
|
169
176
|
grid.appendChild(button)
|
|
170
177
|
}
|
|
171
|
-
this.dialog.open({ template: element, cancel: false, accept: false })
|
|
178
|
+
this.dialog.open({ template: element, cancel: false, accept: false, back: false })
|
|
172
179
|
}
|
|
173
180
|
|
|
174
181
|
build() {
|
|
@@ -270,16 +277,12 @@ export default class Importer extends Utils.WithTemplate {
|
|
|
270
277
|
}
|
|
271
278
|
|
|
272
279
|
submit() {
|
|
273
|
-
let hasErrors
|
|
274
280
|
if (this.format === 'umap') {
|
|
275
|
-
|
|
281
|
+
this.full()
|
|
276
282
|
} else if (!this.url) {
|
|
277
|
-
|
|
283
|
+
this.copy()
|
|
278
284
|
} else if (this.action) {
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
if (hasErrors === false) {
|
|
282
|
-
Alert.info(translate('Data successfully imported!'))
|
|
285
|
+
this[this.action]()
|
|
283
286
|
}
|
|
284
287
|
}
|
|
285
288
|
|
|
@@ -294,8 +297,9 @@ export default class Importer extends Utils.WithTemplate {
|
|
|
294
297
|
} else if (this.url) {
|
|
295
298
|
this._umap.importFromUrl(this.url, this.format)
|
|
296
299
|
}
|
|
300
|
+
this.onSuccess()
|
|
297
301
|
} catch (e) {
|
|
298
|
-
|
|
302
|
+
this.onError(translate('Invalid umap data'))
|
|
299
303
|
console.error(e)
|
|
300
304
|
return false
|
|
301
305
|
}
|
|
@@ -306,7 +310,7 @@ export default class Importer extends Utils.WithTemplate {
|
|
|
306
310
|
return false
|
|
307
311
|
}
|
|
308
312
|
if (!this.format) {
|
|
309
|
-
|
|
313
|
+
this.onError(translate('Please choose a format'))
|
|
310
314
|
return false
|
|
311
315
|
}
|
|
312
316
|
const layer = this.layer
|
|
@@ -318,26 +322,67 @@ export default class Importer extends Utils.WithTemplate {
|
|
|
318
322
|
layer.options.remoteData.proxy = true
|
|
319
323
|
layer.options.remoteData.ttl = SCHEMA.ttl.default
|
|
320
324
|
}
|
|
321
|
-
layer.fetchRemoteData(true)
|
|
325
|
+
layer.fetchRemoteData(true).then((features) => {
|
|
326
|
+
if (features?.length) {
|
|
327
|
+
layer.zoomTo()
|
|
328
|
+
this.onSuccess()
|
|
329
|
+
} else {
|
|
330
|
+
this.onError()
|
|
331
|
+
}
|
|
332
|
+
})
|
|
322
333
|
}
|
|
323
334
|
|
|
324
|
-
copy() {
|
|
335
|
+
async copy() {
|
|
325
336
|
// Format may be guessed from file later.
|
|
326
337
|
// Usefull in case of multiple files with different formats.
|
|
327
338
|
if (!this.format && !this.files.length) {
|
|
328
|
-
|
|
339
|
+
this.onError(translate('Please choose a format'))
|
|
329
340
|
return false
|
|
330
341
|
}
|
|
342
|
+
let promise
|
|
331
343
|
const layer = this.layer
|
|
332
344
|
if (this.clear) layer.empty()
|
|
333
345
|
if (this.files.length) {
|
|
334
|
-
|
|
335
|
-
this._umap.processFileToImport(file, layer, this.format)
|
|
336
|
-
}
|
|
346
|
+
promise = layer.importFromFiles(this.files, this.format)
|
|
337
347
|
} else if (this.raw) {
|
|
338
|
-
layer.importRaw(this.raw, this.format)
|
|
348
|
+
promise = layer.importRaw(this.raw, this.format)
|
|
339
349
|
} else if (this.url) {
|
|
340
|
-
layer.importFromUrl(this.url, this.format)
|
|
350
|
+
promise = layer.importFromUrl(this.url, this.format)
|
|
351
|
+
}
|
|
352
|
+
if (promise) promise.then((data) => this.onCopyFinished(layer, data))
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
onError(message = translate('No data has been found for import')) {
|
|
356
|
+
Alert.error(message)
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
onSuccess(count) {
|
|
360
|
+
if (count) {
|
|
361
|
+
Alert.success(
|
|
362
|
+
translate('Successfully imported {count} feature(s)', {
|
|
363
|
+
count: count,
|
|
364
|
+
})
|
|
365
|
+
)
|
|
366
|
+
} else {
|
|
367
|
+
Alert.success(translate('Data successfully imported!'))
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
onCopyFinished(layer, features) {
|
|
372
|
+
// undefined features means error, let original error message pop
|
|
373
|
+
if (!features) return
|
|
374
|
+
if (!features.length) {
|
|
375
|
+
this.onError()
|
|
376
|
+
} else {
|
|
377
|
+
const bounds = new LatLngBounds()
|
|
378
|
+
for (const feature of features) {
|
|
379
|
+
const featureBounds = feature.ui.getBounds
|
|
380
|
+
? feature.ui.getBounds()
|
|
381
|
+
: feature.ui.getCenter()
|
|
382
|
+
bounds.extend(featureBounds)
|
|
383
|
+
}
|
|
384
|
+
this.onSuccess(features.length)
|
|
385
|
+
layer.zoomTo(bounds)
|
|
341
386
|
}
|
|
342
387
|
}
|
|
343
388
|
}
|
|
@@ -22,7 +22,7 @@ export function getClass(name) {
|
|
|
22
22
|
|
|
23
23
|
export const RECENT = []
|
|
24
24
|
|
|
25
|
-
const BaseIcon =
|
|
25
|
+
const BaseIcon = DivIcon.extend({
|
|
26
26
|
initialize: function (options) {
|
|
27
27
|
const default_options = {
|
|
28
28
|
iconSize: null, // Made in css
|
|
@@ -86,6 +86,7 @@ const DefaultIcon = BaseIcon.extend({
|
|
|
86
86
|
},
|
|
87
87
|
|
|
88
88
|
_setIconStyles: function (img, name) {
|
|
89
|
+
if (this.feature.isActive()) this.options.className += ' umap-icon-active'
|
|
89
90
|
BaseIcon.prototype._setIconStyles.call(this, img, name)
|
|
90
91
|
const color = this._getColor()
|
|
91
92
|
const opacity = this._getOpacity()
|
|
@@ -233,12 +233,8 @@ const ManageTilelayerMixin = {
|
|
|
233
233
|
},
|
|
234
234
|
|
|
235
235
|
updateTileLayers: function () {
|
|
236
|
-
const callback = (tilelayer) => {
|
|
237
|
-
this.options.tilelayer = tilelayer.toJSON()
|
|
238
|
-
this._umap.isDirty = true
|
|
239
|
-
}
|
|
240
236
|
if (this._controls.tilelayersChooser) {
|
|
241
|
-
this._controls.tilelayersChooser.openSwitcher({
|
|
237
|
+
this._controls.tilelayersChooser.openSwitcher({ edit: true })
|
|
242
238
|
}
|
|
243
239
|
},
|
|
244
240
|
}
|
|
@@ -263,8 +259,12 @@ export const LeafletMap = BaseMap.extend({
|
|
|
263
259
|
this.loader.onAdd(this)
|
|
264
260
|
|
|
265
261
|
if (!this.options.noControl) {
|
|
266
|
-
DomEvent.on(document.body, 'dataloading', (
|
|
267
|
-
|
|
262
|
+
DomEvent.on(document.body, 'dataloading', (event) =>
|
|
263
|
+
this.fire('dataloading', event.detail)
|
|
264
|
+
)
|
|
265
|
+
DomEvent.on(document.body, 'dataload', (event) =>
|
|
266
|
+
this.fire('dataload', event.detail)
|
|
267
|
+
)
|
|
268
268
|
this.on('click', this.closeInplaceToolbar)
|
|
269
269
|
}
|
|
270
270
|
|
|
@@ -238,11 +238,15 @@ export const LeafletMarker = Marker.extend({
|
|
|
238
238
|
},
|
|
239
239
|
|
|
240
240
|
highlight: function () {
|
|
241
|
-
|
|
241
|
+
this.feature.activate()
|
|
242
|
+
this._redraw()
|
|
243
|
+
this._bringToFront()
|
|
242
244
|
},
|
|
243
245
|
|
|
244
246
|
resetHighlight: function () {
|
|
245
|
-
|
|
247
|
+
this.feature.deactivate()
|
|
248
|
+
this._redraw()
|
|
249
|
+
this._resetZIndex()
|
|
246
250
|
},
|
|
247
251
|
|
|
248
252
|
getPopupToolbarAnchor: function () {
|
|
@@ -47,8 +47,8 @@ class BaseRequest {
|
|
|
47
47
|
// In case of error, an alert is sent, but non 20X status are not handled
|
|
48
48
|
// The consumer must check the response status by hand
|
|
49
49
|
export class Request extends BaseRequest {
|
|
50
|
-
fire(name,
|
|
51
|
-
document.body.dispatchEvent(new CustomEvent(name,
|
|
50
|
+
fire(name, detail) {
|
|
51
|
+
document.body.dispatchEvent(new CustomEvent(name, { detail }))
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
async _fetch(method, uri, headers, data) {
|
|
@@ -6,6 +6,7 @@ const TEMPLATE = `
|
|
|
6
6
|
<form method="dialog" data-ref="form">
|
|
7
7
|
<ul class="buttons">
|
|
8
8
|
<li><i class="icon icon-16 icon-close" data-close></i></li>
|
|
9
|
+
<li hidden data-ref="back"><i class="icon icon-16 icon-back"></i></li>
|
|
9
10
|
</ul>
|
|
10
11
|
<h3 data-ref="message" id="${Math.round(Date.now()).toString(36)}"></h3>
|
|
11
12
|
<fieldset data-ref="fieldset" role="document">
|
|
@@ -123,6 +124,10 @@ export default class Dialog extends WithTemplate {
|
|
|
123
124
|
} else {
|
|
124
125
|
this.elements.template.innerHTML = dialog.template || ''
|
|
125
126
|
}
|
|
127
|
+
this.elements.back.hidden = !dialog.back
|
|
128
|
+
if (dialog.back) {
|
|
129
|
+
this.elements.back.addEventListener('click', dialog.back)
|
|
130
|
+
}
|
|
126
131
|
|
|
127
132
|
this.focusable = this.getFocusable()
|
|
128
133
|
this.hasFormData = this.elements.fieldset.elements.length > 0
|
|
@@ -218,6 +218,14 @@ export default class Umap extends ServerStored {
|
|
|
218
218
|
this.fire('seteditedfeature')
|
|
219
219
|
}
|
|
220
220
|
|
|
221
|
+
get activeFeature() {
|
|
222
|
+
return this._activeFeature
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
set activeFeature(feature) {
|
|
226
|
+
this._activeFeature = feature
|
|
227
|
+
}
|
|
228
|
+
|
|
221
229
|
setPropertiesFromQueryString() {
|
|
222
230
|
const asBoolean = (key) => {
|
|
223
231
|
const value = this.searchParams.get(key)
|
|
@@ -316,12 +324,14 @@ export default class Umap extends ServerStored {
|
|
|
316
324
|
dataUrl = this.renderUrl(dataUrl)
|
|
317
325
|
dataUrl = this.proxyUrl(dataUrl)
|
|
318
326
|
const datalayer = this.createDataLayer()
|
|
319
|
-
await datalayer
|
|
327
|
+
await datalayer
|
|
328
|
+
.importFromUrl(dataUrl, dataFormat)
|
|
329
|
+
.then(() => datalayer.zoomTo())
|
|
320
330
|
}
|
|
321
331
|
} else if (data) {
|
|
322
332
|
data = decodeURIComponent(data)
|
|
323
333
|
const datalayer = this.createDataLayer()
|
|
324
|
-
await datalayer.importRaw(data, dataFormat)
|
|
334
|
+
await datalayer.importRaw(data, dataFormat).then(() => datalayer.zoomTo())
|
|
325
335
|
}
|
|
326
336
|
}
|
|
327
337
|
|
|
@@ -568,9 +578,11 @@ export default class Umap extends ServerStored {
|
|
|
568
578
|
}
|
|
569
579
|
this.datalayersLoaded = true
|
|
570
580
|
this.fire('datalayersloaded')
|
|
581
|
+
const toLoad = []
|
|
571
582
|
for (const datalayer of this.datalayersIndex) {
|
|
572
|
-
if (datalayer.showAtLoad())
|
|
583
|
+
if (datalayer.showAtLoad()) toLoad.push(datalayer.show())
|
|
573
584
|
}
|
|
585
|
+
await Promise.all(toLoad)
|
|
574
586
|
this.dataloaded = true
|
|
575
587
|
this.fire('dataloaded')
|
|
576
588
|
}
|
|
@@ -641,6 +653,12 @@ export default class Umap extends ServerStored {
|
|
|
641
653
|
// have changed, we'll be more subtil when we'll remove the
|
|
642
654
|
// save action
|
|
643
655
|
this.render(['name', 'user', 'permissions'])
|
|
656
|
+
if (!this._leafletMap.listens('saved')) {
|
|
657
|
+
// When we save only layers, we don't have the map feedback message
|
|
658
|
+
this._leafletMap.on('saved', () => {
|
|
659
|
+
Alert.success(translate('Map has been saved!'))
|
|
660
|
+
})
|
|
661
|
+
}
|
|
644
662
|
this.fire('saved')
|
|
645
663
|
}
|
|
646
664
|
|
|
@@ -1182,7 +1200,7 @@ export default class Umap extends ServerStored {
|
|
|
1182
1200
|
geometry() {
|
|
1183
1201
|
/* Return a GeoJSON geometry Object */
|
|
1184
1202
|
const latlng = this._leafletMap.latLng(
|
|
1185
|
-
this.
|
|
1203
|
+
this.properties.center || this._leafletMap.getCenter()
|
|
1186
1204
|
)
|
|
1187
1205
|
return {
|
|
1188
1206
|
type: 'Point',
|
|
@@ -1424,9 +1442,14 @@ export default class Umap extends ServerStored {
|
|
|
1424
1442
|
const row = DomUtil.create('li', 'orderable', ul)
|
|
1425
1443
|
DomUtil.createIcon(row, 'icon-drag', translate('Drag to reorder'))
|
|
1426
1444
|
datalayer.renderToolbox(row)
|
|
1427
|
-
const
|
|
1445
|
+
const builder = new U.FormBuilder(
|
|
1446
|
+
datalayer,
|
|
1447
|
+
[['options.name', { handler: 'EditableText' }]],
|
|
1448
|
+
{ className: 'umap-form-inline' }
|
|
1449
|
+
)
|
|
1450
|
+
const form = builder.build()
|
|
1451
|
+
row.appendChild(form)
|
|
1428
1452
|
row.classList.toggle('off', !datalayer.isVisible())
|
|
1429
|
-
title.textContent = datalayer.options.name
|
|
1430
1453
|
row.dataset.id = stamp(datalayer)
|
|
1431
1454
|
})
|
|
1432
1455
|
const onReorder = (src, dst, initialIndex, finalIndex) => {
|
|
@@ -1514,7 +1537,7 @@ export default class Umap extends ServerStored {
|
|
|
1514
1537
|
processFileToImport(file, layer, type) {
|
|
1515
1538
|
type = type || Utils.detectFileType(file)
|
|
1516
1539
|
if (!type) {
|
|
1517
|
-
|
|
1540
|
+
Alert.error(
|
|
1518
1541
|
translate('Unable to detect format of file {filename}', {
|
|
1519
1542
|
filename: file.name,
|
|
1520
1543
|
})
|
|
@@ -1660,8 +1683,8 @@ export default class Umap extends ServerStored {
|
|
|
1660
1683
|
}
|
|
1661
1684
|
|
|
1662
1685
|
_setCenterAndZoom() {
|
|
1663
|
-
this.
|
|
1664
|
-
this.
|
|
1686
|
+
this.properties.center = this._leafletMap.getCenter()
|
|
1687
|
+
this.properties.zoom = this._leafletMap.getZoom()
|
|
1665
1688
|
this.isDirty = true
|
|
1666
1689
|
this._defaultExtent = false
|
|
1667
1690
|
}
|
|
@@ -683,10 +683,13 @@ U.TileLayerChooser = L.Control.extend({
|
|
|
683
683
|
L.DomEvent.on(
|
|
684
684
|
el,
|
|
685
685
|
'click',
|
|
686
|
-
|
|
686
|
+
() => {
|
|
687
687
|
this.map.selectTileLayer(tilelayer)
|
|
688
688
|
this.map._controls.tilelayers.setLayers()
|
|
689
|
-
if (options?.
|
|
689
|
+
if (options?.edit) {
|
|
690
|
+
this.map._umap.properties.tilelayer = tilelayer.toJSON()
|
|
691
|
+
this.map._umap.isDirty = true
|
|
692
|
+
}
|
|
690
693
|
},
|
|
691
694
|
this
|
|
692
695
|
)
|
|
@@ -942,11 +945,11 @@ L.Control.Loading.include({
|
|
|
942
945
|
},
|
|
943
946
|
|
|
944
947
|
_showIndicator: function () {
|
|
945
|
-
|
|
948
|
+
this._map._container.classList.add('umap-loading')
|
|
946
949
|
},
|
|
947
950
|
|
|
948
951
|
_hideIndicator: function () {
|
|
949
|
-
|
|
952
|
+
this._map._container.classList.remove('umap-loading')
|
|
950
953
|
},
|
|
951
954
|
})
|
|
952
955
|
|