umap-project 1.4.3__py3-none-any.whl → 1.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.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +29 -28
- umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- umap/locale/cs_CZ/LC_MESSAGES/django.po +35 -35
- umap/locale/en/LC_MESSAGES/django.po +28 -28
- umap/migrations/0010_alter_map_edit_status_alter_map_share_status.py +23 -0
- umap/migrations/0011_alter_map_edit_status_alter_map_share_status.py +24 -0
- umap/models.py +10 -2
- umap/settings/base.py +2 -0
- umap/static/umap/base.css +4 -4
- umap/static/umap/img/16-white.svg +18 -3
- umap/static/umap/img/logo_small.svg +14 -0
- umap/static/umap/img/source/16-white.svg +19 -5
- umap/static/umap/js/umap.controls.js +122 -132
- umap/static/umap/js/umap.core.js +13 -6
- umap/static/umap/js/umap.features.js +41 -15
- umap/static/umap/js/umap.forms.js +55 -5
- umap/static/umap/js/umap.js +59 -100
- umap/static/umap/js/umap.layer.js +69 -26
- umap/static/umap/js/umap.permissions.js +5 -0
- umap/static/umap/js/umap.popup.js +3 -6
- umap/static/umap/js/umap.xhr.js +2 -1
- umap/static/umap/locale/am_ET.js +14 -7
- umap/static/umap/locale/am_ET.json +14 -7
- umap/static/umap/locale/ar.js +14 -7
- umap/static/umap/locale/ar.json +14 -7
- umap/static/umap/locale/ast.js +14 -7
- umap/static/umap/locale/ast.json +14 -7
- umap/static/umap/locale/bg.js +14 -7
- umap/static/umap/locale/bg.json +14 -7
- umap/static/umap/locale/br.js +149 -142
- umap/static/umap/locale/br.json +149 -142
- umap/static/umap/locale/ca.js +14 -7
- umap/static/umap/locale/ca.json +14 -7
- umap/static/umap/locale/cs_CZ.js +42 -35
- umap/static/umap/locale/cs_CZ.json +42 -35
- umap/static/umap/locale/da.js +14 -7
- umap/static/umap/locale/da.json +14 -7
- umap/static/umap/locale/de.js +14 -7
- umap/static/umap/locale/de.json +14 -7
- umap/static/umap/locale/el.js +14 -7
- umap/static/umap/locale/el.json +14 -7
- umap/static/umap/locale/en.js +14 -7
- umap/static/umap/locale/en.json +14 -7
- umap/static/umap/locale/en_US.json +14 -7
- umap/static/umap/locale/es.js +14 -7
- umap/static/umap/locale/es.json +14 -7
- umap/static/umap/locale/et.js +14 -7
- umap/static/umap/locale/et.json +14 -7
- umap/static/umap/locale/eu.js +7 -7
- umap/static/umap/locale/eu.json +7 -7
- umap/static/umap/locale/fa_IR.js +14 -7
- umap/static/umap/locale/fa_IR.json +14 -7
- umap/static/umap/locale/fi.js +14 -7
- umap/static/umap/locale/fi.json +14 -7
- umap/static/umap/locale/fr.js +14 -7
- umap/static/umap/locale/fr.json +14 -7
- umap/static/umap/locale/gl.js +14 -7
- umap/static/umap/locale/gl.json +14 -7
- umap/static/umap/locale/he.js +14 -7
- umap/static/umap/locale/he.json +14 -7
- umap/static/umap/locale/hr.js +14 -7
- umap/static/umap/locale/hr.json +14 -7
- umap/static/umap/locale/hu.js +14 -7
- umap/static/umap/locale/hu.json +14 -7
- umap/static/umap/locale/id.js +14 -7
- umap/static/umap/locale/id.json +14 -7
- umap/static/umap/locale/is.js +14 -7
- umap/static/umap/locale/is.json +14 -7
- umap/static/umap/locale/it.js +14 -7
- umap/static/umap/locale/it.json +14 -7
- umap/static/umap/locale/ja.js +14 -7
- umap/static/umap/locale/ja.json +14 -7
- umap/static/umap/locale/ko.js +14 -7
- umap/static/umap/locale/ko.json +14 -7
- umap/static/umap/locale/lt.js +14 -7
- umap/static/umap/locale/lt.json +14 -7
- umap/static/umap/locale/ms.js +14 -7
- umap/static/umap/locale/ms.json +14 -7
- umap/static/umap/locale/nl.js +14 -7
- umap/static/umap/locale/nl.json +14 -7
- umap/static/umap/locale/no.js +14 -7
- umap/static/umap/locale/no.json +14 -7
- umap/static/umap/locale/pl.js +14 -7
- umap/static/umap/locale/pl.json +14 -7
- umap/static/umap/locale/pl_PL.json +14 -7
- umap/static/umap/locale/pt.js +14 -7
- umap/static/umap/locale/pt.json +14 -7
- umap/static/umap/locale/pt_BR.js +14 -7
- umap/static/umap/locale/pt_BR.json +14 -7
- umap/static/umap/locale/pt_PT.js +14 -7
- umap/static/umap/locale/pt_PT.json +14 -7
- umap/static/umap/locale/ro.js +14 -7
- umap/static/umap/locale/ro.json +14 -7
- umap/static/umap/locale/ru.js +14 -7
- umap/static/umap/locale/ru.json +14 -7
- umap/static/umap/locale/sk_SK.js +14 -7
- umap/static/umap/locale/sk_SK.json +14 -7
- umap/static/umap/locale/sl.js +14 -7
- umap/static/umap/locale/sl.json +14 -7
- umap/static/umap/locale/sr.js +14 -7
- umap/static/umap/locale/sr.json +14 -7
- umap/static/umap/locale/sv.js +38 -31
- umap/static/umap/locale/sv.json +38 -31
- umap/static/umap/locale/th_TH.js +14 -7
- umap/static/umap/locale/th_TH.json +14 -7
- umap/static/umap/locale/tr.js +14 -7
- umap/static/umap/locale/tr.json +14 -7
- umap/static/umap/locale/uk_UA.js +14 -7
- umap/static/umap/locale/uk_UA.json +14 -7
- umap/static/umap/locale/vi.js +14 -7
- umap/static/umap/locale/vi.json +14 -7
- umap/static/umap/locale/vi_VN.json +14 -7
- umap/static/umap/locale/zh.js +14 -7
- umap/static/umap/locale/zh.json +14 -7
- umap/static/umap/locale/zh_CN.json +14 -7
- umap/static/umap/locale/zh_TW.Big5.json +14 -7
- umap/static/umap/locale/zh_TW.js +14 -7
- umap/static/umap/locale/zh_TW.json +14 -7
- umap/static/umap/map.css +119 -47
- umap/static/umap/test/DataLayer.js +32 -6
- umap/static/umap/test/Permissions.js +2 -2
- umap/static/umap/test/Util.js +26 -7
- umap/static/umap/vendors/leaflet/leaflet-src.js +7156 -7156
- umap/static/umap/vendors/togeojson/togeojson.js +2 -406
- umap/tests/test_map.py +16 -0
- umap/tests/test_views.py +18 -0
- umap/views.py +4 -2
- {umap_project-1.4.3.dist-info → umap_project-1.5.0.dist-info}/METADATA +3 -3
- {umap_project-1.4.3.dist-info → umap_project-1.5.0.dist-info}/RECORD +134 -131
- {umap_project-1.4.3.dist-info → umap_project-1.5.0.dist-info}/WHEEL +0 -0
- {umap_project-1.4.3.dist-info → umap_project-1.5.0.dist-info}/entry_points.txt +0 -0
- {umap_project-1.4.3.dist-info → umap_project-1.5.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -86,7 +86,13 @@ L.U.FeatureMixin = {
|
|
|
86
86
|
|
|
87
87
|
edit: function (e) {
|
|
88
88
|
if (!this.map.editEnabled || this.isReadOnly()) return
|
|
89
|
-
const container = L.DomUtil.create('div', 'umap-
|
|
89
|
+
const container = L.DomUtil.create('div', 'umap-feature-container')
|
|
90
|
+
L.DomUtil.add(
|
|
91
|
+
'h3',
|
|
92
|
+
`umap-feature-properties ${this.getClassName()}`,
|
|
93
|
+
container,
|
|
94
|
+
L._('Feature properties')
|
|
95
|
+
)
|
|
90
96
|
|
|
91
97
|
let builder = new L.U.FormBuilder(this, ['datalayer'], {
|
|
92
98
|
callback: function () {
|
|
@@ -184,7 +190,7 @@ L.U.FeatureMixin = {
|
|
|
184
190
|
if (fallback === undefined) fallback = this.datalayer.options.name
|
|
185
191
|
const key = this.getOption('labelKey') || 'name'
|
|
186
192
|
// Variables mode.
|
|
187
|
-
if (
|
|
193
|
+
if (L.Util.hasVar(key))
|
|
188
194
|
return L.Util.greedyTemplate(key, this.extendedProperties())
|
|
189
195
|
// Simple mode.
|
|
190
196
|
return this.properties[key] || this.properties.title || fallback
|
|
@@ -276,11 +282,9 @@ L.U.FeatureMixin = {
|
|
|
276
282
|
getDynamicOption: function (option, fallback) {
|
|
277
283
|
let value = this.getOption(option, fallback)
|
|
278
284
|
// There is a variable inside.
|
|
279
|
-
if (
|
|
280
|
-
value = L.Util.greedyTemplate(value, this.properties)
|
|
281
|
-
|
|
282
|
-
// so we can set a decent default at next step.
|
|
283
|
-
if (value.indexOf('{') != -1) value = undefined
|
|
285
|
+
if (L.Util.hasVar(value)) {
|
|
286
|
+
value = L.Util.greedyTemplate(value, this.properties, true)
|
|
287
|
+
if (L.Util.hasVar(value)) value = this.map.getDefaultOption(option)
|
|
284
288
|
}
|
|
285
289
|
return value
|
|
286
290
|
},
|
|
@@ -444,6 +448,7 @@ L.U.FeatureMixin = {
|
|
|
444
448
|
},
|
|
445
449
|
|
|
446
450
|
resetTooltip: function () {
|
|
451
|
+
if (!this.hasGeom()) return
|
|
447
452
|
const displayName = this.getDisplayName(null)
|
|
448
453
|
let showLabel = this.getOption('showLabel')
|
|
449
454
|
const oldLabelHover = this.getOption('labelHover')
|
|
@@ -469,6 +474,17 @@ L.U.FeatureMixin = {
|
|
|
469
474
|
return false
|
|
470
475
|
},
|
|
471
476
|
|
|
477
|
+
matchFacets: function () {
|
|
478
|
+
const facets = this.map.facets
|
|
479
|
+
for (const [property, expected] of Object.entries(facets)) {
|
|
480
|
+
if (expected.length) {
|
|
481
|
+
let value = this.properties[property]
|
|
482
|
+
if (!value || !expected.includes(value)) return false
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
return true
|
|
486
|
+
},
|
|
487
|
+
|
|
472
488
|
onVertexRawClick: function (e) {
|
|
473
489
|
new L.Toolbar.Popup(e.latlng, {
|
|
474
490
|
className: 'leaflet-inplace-toolbar',
|
|
@@ -494,15 +510,17 @@ L.U.FeatureMixin = {
|
|
|
494
510
|
extendedProperties: function () {
|
|
495
511
|
// Include context properties
|
|
496
512
|
properties = this.map.getGeoContext()
|
|
497
|
-
center = this.getCenter()
|
|
498
|
-
properties.lat = center.lat
|
|
499
|
-
properties.lon = center.lng
|
|
500
|
-
properties.lng = center.lng
|
|
501
|
-
properties.rank = this.getRank() + 1
|
|
502
513
|
if (L.locale) properties.locale = L.locale
|
|
503
514
|
if (L.lang) properties.lang = L.lang
|
|
504
|
-
|
|
505
|
-
|
|
515
|
+
properties.rank = this.getRank() + 1
|
|
516
|
+
if (this.hasGeom()) {
|
|
517
|
+
center = this.getCenter()
|
|
518
|
+
properties.lat = center.lat
|
|
519
|
+
properties.lon = center.lng
|
|
520
|
+
properties.lng = center.lng
|
|
521
|
+
if (typeof this.getMeasure !== 'undefined') {
|
|
522
|
+
properties.measure = this.getMeasure()
|
|
523
|
+
}
|
|
506
524
|
}
|
|
507
525
|
return L.extend(properties, this.properties)
|
|
508
526
|
},
|
|
@@ -535,6 +553,10 @@ L.U.Marker = L.Marker.extend({
|
|
|
535
553
|
this._popupHandlersAdded = true // prevent Leaflet from binding event on bindPopup
|
|
536
554
|
},
|
|
537
555
|
|
|
556
|
+
hasGeom: function () {
|
|
557
|
+
return !!this._latlng
|
|
558
|
+
},
|
|
559
|
+
|
|
538
560
|
_onMouseOut: function () {
|
|
539
561
|
if (
|
|
540
562
|
this.dragging &&
|
|
@@ -581,7 +603,7 @@ L.U.Marker = L.Marker.extend({
|
|
|
581
603
|
},
|
|
582
604
|
|
|
583
605
|
_getTooltipAnchor: function () {
|
|
584
|
-
const anchor = this.options.icon.options.tooltipAnchor,
|
|
606
|
+
const anchor = this.options.icon.options.tooltipAnchor.clone(),
|
|
585
607
|
direction = this.getOption('labelDirection')
|
|
586
608
|
if (direction === 'left') {
|
|
587
609
|
anchor.x *= -1
|
|
@@ -679,6 +701,10 @@ L.U.Marker = L.Marker.extend({
|
|
|
679
701
|
})
|
|
680
702
|
|
|
681
703
|
L.U.PathMixin = {
|
|
704
|
+
hasGeom: function () {
|
|
705
|
+
return !this.isEmpty()
|
|
706
|
+
},
|
|
707
|
+
|
|
682
708
|
connectToDataLayer: function (datalayer) {
|
|
683
709
|
L.U.FeatureMixin.connectToDataLayer.call(this, datalayer)
|
|
684
710
|
// We keep markers on their own layer on top of the paths.
|
|
@@ -417,12 +417,21 @@ L.FormBuilder.DataLayerSwitcher = L.FormBuilder.Select.extend({
|
|
|
417
417
|
},
|
|
418
418
|
})
|
|
419
419
|
|
|
420
|
-
L.FormBuilder.
|
|
420
|
+
L.FormBuilder.DefaultView = L.FormBuilder.Select.extend({
|
|
421
|
+
selectOptions: [
|
|
422
|
+
['center', L._('Saved center and zoom')],
|
|
423
|
+
['bounds', L._('Layers bounds')],
|
|
424
|
+
['latest', L._('Latest feature')],
|
|
425
|
+
['locate', L._('User location')],
|
|
426
|
+
],
|
|
427
|
+
})
|
|
428
|
+
|
|
429
|
+
L.FormBuilder.OnLoadPanel = L.FormBuilder.Select.extend({
|
|
421
430
|
selectOptions: [
|
|
422
431
|
['none', L._('None')],
|
|
423
432
|
['caption', L._('Caption')],
|
|
424
433
|
['databrowser', L._('Data browser')],
|
|
425
|
-
['
|
|
434
|
+
['facet', L._('Facet search')],
|
|
426
435
|
],
|
|
427
436
|
})
|
|
428
437
|
|
|
@@ -533,7 +542,7 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
|
|
|
533
542
|
},
|
|
534
543
|
|
|
535
544
|
udpatePreview: function () {
|
|
536
|
-
if (
|
|
545
|
+
if (L.Util.hasVar(this.value())) {
|
|
537
546
|
// Do not try to render URL with variables
|
|
538
547
|
if (this.isUrl()) {
|
|
539
548
|
const img = L.DomUtil.create(
|
|
@@ -675,6 +684,37 @@ L.FormBuilder.Switch = L.FormBuilder.CheckBox.extend({
|
|
|
675
684
|
},
|
|
676
685
|
})
|
|
677
686
|
|
|
687
|
+
L.FormBuilder.FacetSearch = L.FormBuilder.Element.extend({
|
|
688
|
+
build: function () {
|
|
689
|
+
this.container = L.DomUtil.create('div', 'umap-facet', this.parentNode)
|
|
690
|
+
this.ul = L.DomUtil.create('ul', '', this.container)
|
|
691
|
+
const choices = this.options.choices
|
|
692
|
+
choices.sort()
|
|
693
|
+
choices.forEach((value) => this.buildLi(value))
|
|
694
|
+
},
|
|
695
|
+
|
|
696
|
+
buildLabel: function () {
|
|
697
|
+
this.label = L.DomUtil.add('h5', '', this.parentNode, this.options.label);
|
|
698
|
+
},
|
|
699
|
+
|
|
700
|
+
buildLi: function (value) {
|
|
701
|
+
const property_li = L.DomUtil.create('li', '', this.ul),
|
|
702
|
+
input = L.DomUtil.create('input', '', property_li),
|
|
703
|
+
label = L.DomUtil.create('label', '', property_li)
|
|
704
|
+
input.type = 'checkbox'
|
|
705
|
+
input.id = `checkbox_${this.name}_${value}`
|
|
706
|
+
input.checked = this.get().includes(value)
|
|
707
|
+
input.dataset.value = value
|
|
708
|
+
label.htmlFor = `checkbox_${this.name}_${value}`
|
|
709
|
+
label.innerHTML = value
|
|
710
|
+
L.DomEvent.on(input, 'change', (e) => this.sync())
|
|
711
|
+
},
|
|
712
|
+
|
|
713
|
+
toJS: function () {
|
|
714
|
+
return [...this.ul.querySelectorAll('input:checked')].map(i => i.dataset.value)
|
|
715
|
+
},
|
|
716
|
+
})
|
|
717
|
+
|
|
678
718
|
L.FormBuilder.MultiChoice = L.FormBuilder.Element.extend({
|
|
679
719
|
default: 'null',
|
|
680
720
|
className: 'umap-multiplechoice',
|
|
@@ -1008,9 +1048,13 @@ L.U.FormBuilder = L.FormBuilder.extend({
|
|
|
1008
1048
|
label: L._('Do you want to display the scale control?'),
|
|
1009
1049
|
},
|
|
1010
1050
|
onLoadPanel: {
|
|
1011
|
-
handler: '
|
|
1051
|
+
handler: 'OnLoadPanel',
|
|
1012
1052
|
label: L._('Do you want to display a panel on load?'),
|
|
1013
1053
|
},
|
|
1054
|
+
defaultView: {
|
|
1055
|
+
handler: 'DefaultView',
|
|
1056
|
+
label: L._('Default view'),
|
|
1057
|
+
},
|
|
1014
1058
|
displayPopupFooter: {
|
|
1015
1059
|
handler: 'Switch',
|
|
1016
1060
|
label: L._('Do you want to display popup footer?'),
|
|
@@ -1096,6 +1140,12 @@ L.U.FormBuilder = L.FormBuilder.extend({
|
|
|
1096
1140
|
handler: 'ControlChoice',
|
|
1097
1141
|
label: L._('Display the star map button'),
|
|
1098
1142
|
},
|
|
1143
|
+
fromZoom: {
|
|
1144
|
+
handler: 'IntInput',
|
|
1145
|
+
label: L._('From zoom'),
|
|
1146
|
+
helpText: L._('Optional.'),
|
|
1147
|
+
},
|
|
1148
|
+
toZoom: { handler: 'IntInput', label: L._('To zoom'), helpText: L._('Optional.') },
|
|
1099
1149
|
},
|
|
1100
1150
|
|
|
1101
1151
|
initialize: function (obj, fields, options) {
|
|
@@ -1106,7 +1156,7 @@ L.U.FormBuilder = L.FormBuilder.extend({
|
|
|
1106
1156
|
|
|
1107
1157
|
setter: function (field, value) {
|
|
1108
1158
|
L.FormBuilder.prototype.setter.call(this, field, value)
|
|
1109
|
-
this.obj.isDirty = true
|
|
1159
|
+
if (this.options.makeDirty !== false) this.obj.isDirty = true
|
|
1110
1160
|
},
|
|
1111
1161
|
|
|
1112
1162
|
finish: function () {
|
umap/static/umap/js/umap.js
CHANGED
|
@@ -67,13 +67,11 @@ L.U.Map.include({
|
|
|
67
67
|
initialize: function (el, geojson) {
|
|
68
68
|
// Locale name (pt_PT, en_US…)
|
|
69
69
|
// To be used for Django localization
|
|
70
|
-
if (geojson.properties.locale)
|
|
71
|
-
L.setLocale(geojson.properties.locale)
|
|
70
|
+
if (geojson.properties.locale) L.setLocale(geojson.properties.locale)
|
|
72
71
|
|
|
73
72
|
// Language code (pt-pt, en-us…)
|
|
74
73
|
// To be used in javascript APIs
|
|
75
|
-
if (geojson.properties.lang)
|
|
76
|
-
L.lang = geojson.properties.lang
|
|
74
|
+
if (geojson.properties.lang) L.lang = geojson.properties.lang
|
|
77
75
|
|
|
78
76
|
// Don't let default autocreation of controls
|
|
79
77
|
const zoomControl =
|
|
@@ -91,7 +89,7 @@ L.U.Map.include({
|
|
|
91
89
|
|
|
92
90
|
this.ui = new L.U.UI(this._container)
|
|
93
91
|
this.xhr = new L.U.Xhr(this.ui)
|
|
94
|
-
this.xhr.on('dataloading',
|
|
92
|
+
this.xhr.on('dataloading', (e) => this.fire('dataloading', e))
|
|
95
93
|
this.xhr.on('dataload', (e) => this.fire('dataload', e))
|
|
96
94
|
|
|
97
95
|
this.initLoader()
|
|
@@ -144,18 +142,6 @@ L.U.Map.include({
|
|
|
144
142
|
// Certainly IE8, which has a limited version of defineProperty
|
|
145
143
|
}
|
|
146
144
|
|
|
147
|
-
if (this.options.hash) this.addHash()
|
|
148
|
-
this.initCenter()
|
|
149
|
-
this.handleLimitBounds()
|
|
150
|
-
|
|
151
|
-
this.initTileLayers(this.options.tilelayers)
|
|
152
|
-
|
|
153
|
-
// Global storage for retrieving datalayers and features
|
|
154
|
-
this.datalayers = {}
|
|
155
|
-
this.datalayers_index = []
|
|
156
|
-
this.dirty_datalayers = []
|
|
157
|
-
this.features_index = {}
|
|
158
|
-
|
|
159
145
|
// Retrocompat
|
|
160
146
|
if (
|
|
161
147
|
this.options.slideshow &&
|
|
@@ -163,10 +149,20 @@ L.U.Map.include({
|
|
|
163
149
|
this.options.slideshow.active === undefined
|
|
164
150
|
)
|
|
165
151
|
this.options.slideshow.active = true
|
|
152
|
+
if (this.options.advancedFilterKey) this.options.facetKey = this.options.advancedFilterKey
|
|
166
153
|
|
|
167
|
-
|
|
154
|
+
// Global storage for retrieving datalayers and features
|
|
155
|
+
this.datalayers = {}
|
|
156
|
+
this.datalayers_index = []
|
|
157
|
+
this.dirty_datalayers = []
|
|
158
|
+
this.features_index = {}
|
|
159
|
+
this.facets = {}
|
|
168
160
|
|
|
169
|
-
|
|
161
|
+
if (this.options.hash) this.addHash()
|
|
162
|
+
this.initControls()
|
|
163
|
+
this.initCenter()
|
|
164
|
+
this.handleLimitBounds()
|
|
165
|
+
this.initTileLayers(this.options.tilelayers)
|
|
170
166
|
this.initDatalayers()
|
|
171
167
|
|
|
172
168
|
if (this.options.displayCaptionOnLoad) {
|
|
@@ -247,14 +243,14 @@ L.U.Map.include({
|
|
|
247
243
|
},
|
|
248
244
|
this
|
|
249
245
|
)
|
|
250
|
-
this.
|
|
246
|
+
this.renderEditToolbar()
|
|
251
247
|
}
|
|
252
248
|
this.initShortcuts()
|
|
253
249
|
this.onceDatalayersLoaded(function () {
|
|
254
250
|
if (L.Util.queryString('share')) this.renderShareBox()
|
|
255
251
|
else if (this.options.onLoadPanel === 'databrowser') this.openBrowser()
|
|
256
252
|
else if (this.options.onLoadPanel === 'caption') this.displayCaption()
|
|
257
|
-
else if (this.options.onLoadPanel === 'datafilters') this.
|
|
253
|
+
else if (this.options.onLoadPanel === 'facet' || this.options.onLoadPanel === 'datafilters') this.openFacet()
|
|
258
254
|
})
|
|
259
255
|
this.onceDataLoaded(function () {
|
|
260
256
|
const slug = L.Util.queryString('feature')
|
|
@@ -636,10 +632,16 @@ L.U.Map.include({
|
|
|
636
632
|
if (this.options.hash && this._hash.parseHash(location.hash)) {
|
|
637
633
|
// FIXME An invalid hash will cause the load to fail
|
|
638
634
|
this._hash.update()
|
|
639
|
-
} else if (this.options.locate && this.options.
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
this.
|
|
635
|
+
} else if (this.options.defaultView === 'locate' && !this.options.noControl) {
|
|
636
|
+
this._controls.locate.start()
|
|
637
|
+
} else if (this.options.defaultView === 'bounds') {
|
|
638
|
+
this.onceDataLoaded(() => this.fitBounds(this.getLayersBounds()))
|
|
639
|
+
} else if (this.options.defaultView === 'latest') {
|
|
640
|
+
this.onceDataLoaded(() => {
|
|
641
|
+
const datalayer = this.defaultDataLayer(),
|
|
642
|
+
feature = datalayer.getFeatureByIndex(-1)
|
|
643
|
+
if (feature) feature.zoomTo()
|
|
644
|
+
})
|
|
643
645
|
} else {
|
|
644
646
|
this.options.center = this.latLng(this.options.center)
|
|
645
647
|
this.setView(this.options.center, this.options.zoom)
|
|
@@ -951,9 +953,9 @@ L.U.Map.include({
|
|
|
951
953
|
})
|
|
952
954
|
},
|
|
953
955
|
|
|
954
|
-
|
|
956
|
+
openFacet: function () {
|
|
955
957
|
this.onceDatalayersLoaded(function () {
|
|
956
|
-
this.
|
|
958
|
+
this._openFacet()
|
|
957
959
|
})
|
|
958
960
|
},
|
|
959
961
|
|
|
@@ -1036,6 +1038,7 @@ L.U.Map.include({
|
|
|
1036
1038
|
'miniMap',
|
|
1037
1039
|
'displayPopupFooter',
|
|
1038
1040
|
'onLoadPanel',
|
|
1041
|
+
'defaultView',
|
|
1039
1042
|
'tilelayersControl',
|
|
1040
1043
|
'name',
|
|
1041
1044
|
'description',
|
|
@@ -1064,7 +1067,7 @@ L.U.Map.include({
|
|
|
1064
1067
|
'sortKey',
|
|
1065
1068
|
'labelKey',
|
|
1066
1069
|
'filterKey',
|
|
1067
|
-
'
|
|
1070
|
+
'facetKey',
|
|
1068
1071
|
'slugKey',
|
|
1069
1072
|
'showLabel',
|
|
1070
1073
|
'labelDirection',
|
|
@@ -1273,6 +1276,9 @@ L.U.Map.include({
|
|
|
1273
1276
|
}
|
|
1274
1277
|
},
|
|
1275
1278
|
|
|
1279
|
+
// TODO: allow to control the default datalayer
|
|
1280
|
+
// (edit and viewing)
|
|
1281
|
+
// cf https://github.com/umap-project/umap/issues/585
|
|
1276
1282
|
defaultDataLayer: function () {
|
|
1277
1283
|
let datalayer, fallback
|
|
1278
1284
|
datalayer = this.lastUsedDataLayer
|
|
@@ -1314,6 +1320,7 @@ L.U.Map.include({
|
|
|
1314
1320
|
'options.miniMap',
|
|
1315
1321
|
'options.scaleControl',
|
|
1316
1322
|
'options.onLoadPanel',
|
|
1323
|
+
'options.defaultView',
|
|
1317
1324
|
'options.displayPopupFooter',
|
|
1318
1325
|
'options.captionBar',
|
|
1319
1326
|
'options.captionMenus',
|
|
@@ -1387,13 +1394,12 @@ L.U.Map.include({
|
|
|
1387
1394
|
},
|
|
1388
1395
|
],
|
|
1389
1396
|
[
|
|
1390
|
-
'options.
|
|
1397
|
+
'options.facetKey',
|
|
1391
1398
|
{
|
|
1392
1399
|
handler: 'Input',
|
|
1393
|
-
helpEntries: '
|
|
1400
|
+
helpEntries: 'facetKey',
|
|
1394
1401
|
placeholder: L._('Example: key1,key2,key3'),
|
|
1395
|
-
label: L._('
|
|
1396
|
-
inheritable: true,
|
|
1402
|
+
label: L._('Facet keys')
|
|
1397
1403
|
},
|
|
1398
1404
|
],
|
|
1399
1405
|
[
|
|
@@ -1710,7 +1716,7 @@ L.U.Map.include({
|
|
|
1710
1716
|
if (!this.editEnabled) return
|
|
1711
1717
|
const container = L.DomUtil.create('div', 'umap-edit-container'),
|
|
1712
1718
|
metadataFields = ['options.name', 'options.description'],
|
|
1713
|
-
title = L.DomUtil.create('
|
|
1719
|
+
title = L.DomUtil.create('h3', '', container)
|
|
1714
1720
|
title.textContent = L._('Edit map properties')
|
|
1715
1721
|
const builder = new L.U.FormBuilder(this, metadataFields)
|
|
1716
1722
|
const form = builder.build()
|
|
@@ -1778,7 +1784,7 @@ L.U.Map.include({
|
|
|
1778
1784
|
this.openBrowser,
|
|
1779
1785
|
this
|
|
1780
1786
|
)
|
|
1781
|
-
if (this.options.
|
|
1787
|
+
if (this.options.facetKey) {
|
|
1782
1788
|
const filter = L.DomUtil.add(
|
|
1783
1789
|
'a',
|
|
1784
1790
|
'umap-open-filter-link',
|
|
@@ -1789,7 +1795,7 @@ L.U.Map.include({
|
|
|
1789
1795
|
L.DomEvent.on(filter, 'click', L.DomEvent.stop).on(
|
|
1790
1796
|
filter,
|
|
1791
1797
|
'click',
|
|
1792
|
-
this.
|
|
1798
|
+
this.openFacet,
|
|
1793
1799
|
this
|
|
1794
1800
|
)
|
|
1795
1801
|
}
|
|
@@ -1804,66 +1810,6 @@ L.U.Map.include({
|
|
|
1804
1810
|
})
|
|
1805
1811
|
},
|
|
1806
1812
|
|
|
1807
|
-
initEditBar: function () {
|
|
1808
|
-
const container = L.DomUtil.create(
|
|
1809
|
-
'div',
|
|
1810
|
-
'umap-main-edit-toolbox with-transition dark',
|
|
1811
|
-
this._controlContainer
|
|
1812
|
-
),
|
|
1813
|
-
title = L.DomUtil.add('h3', '', container, `${L._('Editing')} `),
|
|
1814
|
-
name = L.DomUtil.create('a', 'umap-click-to-edit', title),
|
|
1815
|
-
setName = function () {
|
|
1816
|
-
name.textContent = this.getDisplayName()
|
|
1817
|
-
}
|
|
1818
|
-
if (this.options.user) {
|
|
1819
|
-
const userLabel = L.DomUtil.add('a', 'umap-user', title, this.options.user.name)
|
|
1820
|
-
userLabel.href = this.options.user.url
|
|
1821
|
-
}
|
|
1822
|
-
L.bind(setName, this)()
|
|
1823
|
-
L.DomEvent.on(name, 'click', this.edit, this)
|
|
1824
|
-
this.on('postsync', L.bind(setName, this))
|
|
1825
|
-
this.help.button(name, 'edit')
|
|
1826
|
-
const save = L.DomUtil.create('a', 'leaflet-control-edit-save button', container)
|
|
1827
|
-
save.href = '#'
|
|
1828
|
-
save.title = `${L._('Save current edits')} (Ctrl+S)`
|
|
1829
|
-
save.textContent = L._('Save')
|
|
1830
|
-
const cancel = L.DomUtil.create(
|
|
1831
|
-
'a',
|
|
1832
|
-
'leaflet-control-edit-cancel button',
|
|
1833
|
-
container
|
|
1834
|
-
)
|
|
1835
|
-
cancel.href = '#'
|
|
1836
|
-
cancel.title = L._('Cancel edits')
|
|
1837
|
-
cancel.textContent = L._('Cancel')
|
|
1838
|
-
const disable = L.DomUtil.create('a', 'leaflet-control-edit-disable', container)
|
|
1839
|
-
disable.href = '#'
|
|
1840
|
-
disable.title = disable.textContent = L._('Disable editing')
|
|
1841
|
-
|
|
1842
|
-
L.DomEvent.addListener(disable, 'click', L.DomEvent.stop).addListener(
|
|
1843
|
-
disable,
|
|
1844
|
-
'click',
|
|
1845
|
-
function (e) {
|
|
1846
|
-
this.disableEdit(e)
|
|
1847
|
-
this.ui.closePanel()
|
|
1848
|
-
},
|
|
1849
|
-
this
|
|
1850
|
-
)
|
|
1851
|
-
|
|
1852
|
-
L.DomEvent.addListener(save, 'click', L.DomEvent.stop).addListener(
|
|
1853
|
-
save,
|
|
1854
|
-
'click',
|
|
1855
|
-
this.save,
|
|
1856
|
-
this
|
|
1857
|
-
)
|
|
1858
|
-
|
|
1859
|
-
L.DomEvent.addListener(cancel, 'click', L.DomEvent.stop).addListener(
|
|
1860
|
-
cancel,
|
|
1861
|
-
'click',
|
|
1862
|
-
this.askForReset,
|
|
1863
|
-
this
|
|
1864
|
-
)
|
|
1865
|
-
},
|
|
1866
|
-
|
|
1867
1813
|
askForReset: function (e) {
|
|
1868
1814
|
if (!confirm(L._('Are you sure you want to cancel your changes?'))) return
|
|
1869
1815
|
this.reset()
|
|
@@ -2007,10 +1953,10 @@ L.U.Map.include({
|
|
|
2007
1953
|
text: L._('Browse data'),
|
|
2008
1954
|
callback: this.openBrowser,
|
|
2009
1955
|
})
|
|
2010
|
-
if (this.options.
|
|
1956
|
+
if (this.options.facetKey) {
|
|
2011
1957
|
items.push({
|
|
2012
|
-
text: L._('
|
|
2013
|
-
callback: this.
|
|
1958
|
+
text: L._('Facet search'),
|
|
1959
|
+
callback: this.openFacet,
|
|
2014
1960
|
})
|
|
2015
1961
|
}
|
|
2016
1962
|
items.push(
|
|
@@ -2095,7 +2041,20 @@ L.U.Map.include({
|
|
|
2095
2041
|
return (this.options.filterKey || this.options.sortKey || 'name').split(',')
|
|
2096
2042
|
},
|
|
2097
2043
|
|
|
2098
|
-
|
|
2099
|
-
return (this.options.
|
|
2044
|
+
getFacetKeys: function () {
|
|
2045
|
+
return (this.options.facetKey || '').split(',').reduce((acc, curr) => {
|
|
2046
|
+
const els = curr.split("|")
|
|
2047
|
+
acc[els[0]] = els[1] || els[0]
|
|
2048
|
+
return acc
|
|
2049
|
+
}, {})
|
|
2050
|
+
},
|
|
2051
|
+
|
|
2052
|
+
getLayersBounds: function () {
|
|
2053
|
+
const bounds = new L.latLngBounds()
|
|
2054
|
+
this.eachBrowsableDataLayer((d) => {
|
|
2055
|
+
if (d.isVisible()) bounds.extend(d.layer.getBounds())
|
|
2056
|
+
})
|
|
2057
|
+
return bounds
|
|
2100
2058
|
},
|
|
2059
|
+
|
|
2101
2060
|
})
|