umap-project 1.14.0a5__py3-none-any.whl → 2.0.0a0__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/decorators.py +0 -14
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +137 -85
- umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- umap/locale/cs_CZ/LC_MESSAGES/django.po +136 -84
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +136 -84
- umap/locale/en/LC_MESSAGES/django.po +128 -88
- umap/locale/es/LC_MESSAGES/django.mo +0 -0
- umap/locale/es/LC_MESSAGES/django.po +136 -84
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +131 -91
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +137 -85
- umap/locale/it/LC_MESSAGES/django.mo +0 -0
- umap/locale/it/LC_MESSAGES/django.po +136 -84
- umap/locale/ms/LC_MESSAGES/django.mo +0 -0
- umap/locale/ms/LC_MESSAGES/django.po +136 -84
- umap/locale/pl/LC_MESSAGES/django.mo +0 -0
- umap/locale/pl/LC_MESSAGES/django.po +136 -84
- umap/locale/sv/LC_MESSAGES/django.mo +0 -0
- umap/locale/sv/LC_MESSAGES/django.po +135 -83
- umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
- umap/locale/zh_TW/LC_MESSAGES/django.po +143 -91
- umap/models.py +23 -1
- umap/settings/__init__.py +1 -4
- umap/settings/base.py +1 -0
- umap/static/umap/base.css +5 -0
- umap/static/umap/content.css +185 -13
- umap/static/umap/favicons/icon.svg +2 -2
- umap/static/umap/img/edit.svg +3 -3
- umap/static/umap/img/icon-delete.svg +4 -0
- umap/static/umap/img/icon-download.svg +13 -0
- umap/static/umap/img/icon-duplicate.svg +5 -0
- umap/static/umap/img/icon-edit.svg +12 -0
- umap/static/umap/img/icon-share.svg +11 -0
- umap/static/umap/img/icon-view.svg +12 -0
- umap/static/umap/img/logo.svg +2 -2
- umap/static/umap/img/logo_small.svg +2 -2
- umap/static/umap/img/marker.svg +4 -0
- umap/static/umap/img/opensource.svg +2 -2
- umap/static/umap/img/osm.svg +2 -2
- umap/static/umap/js/components/fragment.js +1 -1
- umap/static/umap/js/modules/browser.js +159 -0
- umap/static/umap/js/modules/global.js +3 -1
- umap/static/umap/js/modules/request.js +155 -0
- umap/static/umap/js/umap.autocomplete.js +28 -38
- umap/static/umap/js/umap.controls.js +73 -58
- umap/static/umap/js/umap.core.js +4 -9
- umap/static/umap/js/umap.datalayer.permissions.js +13 -12
- umap/static/umap/js/umap.features.js +51 -49
- umap/static/umap/js/umap.forms.js +19 -19
- umap/static/umap/js/umap.icon.js +17 -17
- umap/static/umap/js/umap.importer.js +2 -1
- umap/static/umap/js/umap.js +242 -291
- umap/static/umap/js/umap.layer.js +173 -141
- umap/static/umap/js/umap.permissions.js +24 -25
- umap/static/umap/js/umap.popup.js +14 -14
- umap/static/umap/js/umap.share.js +4 -4
- umap/static/umap/js/umap.slideshow.js +4 -4
- umap/static/umap/js/umap.tableeditor.js +2 -2
- umap/static/umap/js/umap.ui.js +1 -1
- umap/static/umap/locale/am_ET.js +1 -11
- umap/static/umap/locale/am_ET.json +1 -11
- umap/static/umap/locale/ar.js +1 -11
- umap/static/umap/locale/ar.json +1 -11
- umap/static/umap/locale/ast.js +1 -11
- umap/static/umap/locale/ast.json +1 -11
- umap/static/umap/locale/bg.js +1 -11
- umap/static/umap/locale/bg.json +1 -11
- umap/static/umap/locale/br.js +1 -11
- umap/static/umap/locale/br.json +1 -11
- umap/static/umap/locale/ca.js +1 -11
- umap/static/umap/locale/ca.json +1 -11
- umap/static/umap/locale/cs_CZ.js +1 -11
- umap/static/umap/locale/cs_CZ.json +1 -11
- umap/static/umap/locale/da.js +1 -11
- umap/static/umap/locale/da.json +1 -11
- umap/static/umap/locale/de.js +1 -11
- umap/static/umap/locale/de.json +1 -11
- umap/static/umap/locale/el.js +1 -11
- umap/static/umap/locale/el.json +1 -11
- umap/static/umap/locale/en.js +1 -11
- umap/static/umap/locale/en.json +1 -11
- umap/static/umap/locale/en_US.json +1 -11
- umap/static/umap/locale/es.js +1 -11
- umap/static/umap/locale/es.json +1 -11
- umap/static/umap/locale/et.js +1 -11
- umap/static/umap/locale/et.json +1 -11
- umap/static/umap/locale/fa_IR.js +6 -16
- umap/static/umap/locale/fa_IR.json +6 -16
- umap/static/umap/locale/fi.js +1 -11
- umap/static/umap/locale/fi.json +1 -11
- umap/static/umap/locale/fr.js +1 -11
- umap/static/umap/locale/fr.json +1 -11
- umap/static/umap/locale/gl.js +1 -11
- umap/static/umap/locale/gl.json +1 -11
- umap/static/umap/locale/he.js +1 -11
- umap/static/umap/locale/he.json +1 -11
- umap/static/umap/locale/hr.js +1 -11
- umap/static/umap/locale/hr.json +1 -11
- umap/static/umap/locale/hu.js +1 -11
- umap/static/umap/locale/hu.json +1 -11
- umap/static/umap/locale/id.js +1 -11
- umap/static/umap/locale/id.json +1 -11
- umap/static/umap/locale/is.js +1 -11
- umap/static/umap/locale/is.json +1 -11
- umap/static/umap/locale/it.js +1 -11
- umap/static/umap/locale/it.json +1 -11
- umap/static/umap/locale/ja.js +1 -11
- umap/static/umap/locale/ja.json +1 -11
- umap/static/umap/locale/ko.js +1 -11
- umap/static/umap/locale/ko.json +1 -11
- umap/static/umap/locale/lt.js +1 -11
- umap/static/umap/locale/lt.json +1 -11
- umap/static/umap/locale/ms.js +1 -11
- umap/static/umap/locale/ms.json +1 -11
- umap/static/umap/locale/nl.js +1 -11
- umap/static/umap/locale/nl.json +1 -11
- umap/static/umap/locale/no.js +1 -11
- umap/static/umap/locale/no.json +1 -11
- umap/static/umap/locale/pl.js +1 -11
- umap/static/umap/locale/pl.json +1 -11
- umap/static/umap/locale/pl_PL.json +1 -11
- umap/static/umap/locale/pt.js +1 -11
- umap/static/umap/locale/pt.json +1 -11
- umap/static/umap/locale/pt_BR.js +1 -11
- umap/static/umap/locale/pt_BR.json +1 -11
- umap/static/umap/locale/pt_PT.js +1 -11
- umap/static/umap/locale/pt_PT.json +1 -11
- umap/static/umap/locale/ro.js +1 -11
- umap/static/umap/locale/ro.json +1 -11
- umap/static/umap/locale/ru.js +1 -11
- umap/static/umap/locale/ru.json +1 -11
- umap/static/umap/locale/sk_SK.js +1 -11
- umap/static/umap/locale/sk_SK.json +1 -11
- umap/static/umap/locale/sl.js +1 -11
- umap/static/umap/locale/sl.json +1 -11
- umap/static/umap/locale/sr.js +1 -11
- umap/static/umap/locale/sr.json +1 -11
- umap/static/umap/locale/sv.js +1 -11
- umap/static/umap/locale/sv.json +1 -11
- umap/static/umap/locale/th_TH.js +1 -11
- umap/static/umap/locale/th_TH.json +1 -11
- umap/static/umap/locale/tr.js +1 -11
- umap/static/umap/locale/tr.json +1 -11
- umap/static/umap/locale/uk_UA.js +1 -11
- umap/static/umap/locale/uk_UA.json +1 -11
- umap/static/umap/locale/vi.js +1 -11
- umap/static/umap/locale/vi.json +1 -11
- umap/static/umap/locale/vi_VN.json +1 -11
- umap/static/umap/locale/zh.js +1 -11
- umap/static/umap/locale/zh.json +1 -11
- umap/static/umap/locale/zh_CN.json +1 -11
- umap/static/umap/locale/zh_TW.Big5.json +1 -11
- umap/static/umap/locale/zh_TW.js +17 -27
- umap/static/umap/locale/zh_TW.json +17 -27
- umap/static/umap/map.css +2 -2
- umap/static/umap/nav.css +2 -1
- umap/static/umap/test/.eslintrc +0 -1
- umap/static/umap/test/Choropleth.js +29 -27
- umap/static/umap/test/DataLayer.js +207 -239
- umap/static/umap/test/Feature.js +33 -58
- umap/static/umap/test/Map.Export.js +11 -11
- umap/static/umap/test/Map.js +66 -67
- umap/static/umap/test/Marker.js +36 -32
- umap/static/umap/test/Polygon.js +95 -95
- umap/static/umap/test/Polyline.js +31 -31
- umap/static/umap/test/TableEditor.js +29 -25
- umap/static/umap/test/_pre.js +2 -7
- umap/static/umap/test/index.html +4 -4
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.css +54 -0
- umap/static/umap/vendors/contextmenu/leaflet.contextmenu.js +586 -0
- umap/static/umap/vendors/csv2geojson/index.js +259 -0
- umap/static/umap/vendors/dompurify/purify.js +1633 -0
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.css +63 -0
- umap/static/umap/vendors/locatecontrol/L.Control.Locate.js +950 -0
- umap/static/umap/vendors/minimap/Control.MiniMap.css +88 -0
- umap/static/umap/vendors/minimap/Control.MiniMap.js +352 -0
- umap/static/umap/vendors/togeojson/togeojson.js +2 -0
- umap/templates/auth/user_form.html +3 -2
- umap/templates/base.html +1 -0
- umap/templates/registration/login.html +51 -36
- umap/templates/umap/about_summary.html +1 -1
- umap/templates/umap/branding.html +3 -0
- umap/templates/umap/content.html +15 -39
- umap/templates/umap/header.html +0 -0
- umap/templates/umap/home.html +4 -2
- umap/templates/umap/js.html +0 -1
- umap/templates/umap/map_detail.html +9 -0
- umap/templates/umap/map_init.html +1 -1
- umap/templates/umap/map_messages.html +4 -2
- umap/templates/umap/map_table.html +130 -69
- umap/templates/umap/navigation.html +2 -4
- umap/templates/umap/user_dashboard.html +29 -6
- umap/tests/base.py +1 -1
- umap/tests/integration/conftest.py +18 -0
- umap/tests/integration/test_anonymous_owned_map.py +6 -3
- umap/tests/integration/test_browser.py +166 -6
- umap/tests/integration/test_collaborative_editing.py +23 -5
- umap/tests/integration/test_dashboard.py +17 -0
- umap/tests/integration/test_edit_datalayer.py +4 -3
- umap/tests/integration/test_export_map.py +1 -1
- umap/tests/integration/test_import.py +9 -4
- umap/tests/integration/test_map.py +64 -0
- umap/tests/integration/test_map_preview.py +75 -0
- umap/tests/integration/test_owned_map.py +11 -25
- umap/tests/integration/test_picto.py +3 -3
- umap/tests/integration/test_querystring.py +52 -0
- umap/tests/integration/test_share.py +22 -0
- umap/tests/test_map_views.py +157 -14
- umap/tests/test_views.py +50 -11
- umap/urls.py +6 -12
- umap/views.py +170 -47
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/METADATA +13 -15
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/RECORD +220 -199
- umap/static/umap/js/umap.browser.js +0 -148
- umap/static/umap/js/umap.xhr.js +0 -304
- umap/static/umap/test/Controls.js +0 -100
- umap/static/umap/test/Map.Init.js +0 -46
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/WHEEL +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/entry_points.txt +0 -0
- {umap_project-1.14.0a5.dist-info → umap_project-2.0.0a0.dist-info}/licenses/LICENSE +0 -0
umap/static/umap/js/umap.js
CHANGED
|
@@ -34,7 +34,7 @@ L.Map.mergeOptions({
|
|
|
34
34
|
// we cannot rely on this because of the y is overriden by Leaflet
|
|
35
35
|
// See https://github.com/Leaflet/Leaflet/pull/9201
|
|
36
36
|
// And let's remove this -y when this PR is merged and released.
|
|
37
|
-
demoTileInfos: { s: 'a', z: 9, x: 265, y: 181, '-y': 181, r: '' },
|
|
37
|
+
demoTileInfos: { 's': 'a', 'z': 9, 'x': 265, 'y': 181, '-y': 181, 'r': '' },
|
|
38
38
|
licences: [],
|
|
39
39
|
licence: '',
|
|
40
40
|
enableMarkerDraw: true,
|
|
@@ -55,19 +55,66 @@ L.Map.mergeOptions({
|
|
|
55
55
|
featuresHaveOwner: false,
|
|
56
56
|
})
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
'
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
'
|
|
69
|
-
'
|
|
70
|
-
|
|
58
|
+
U.Map = L.Map.extend({
|
|
59
|
+
includes: [ControlsMixin],
|
|
60
|
+
editableOptions: {
|
|
61
|
+
'zoom': undefined,
|
|
62
|
+
'scrollWheelZoom': Boolean,
|
|
63
|
+
'scaleControl': Boolean,
|
|
64
|
+
'moreControl': Boolean,
|
|
65
|
+
'miniMap': Boolean,
|
|
66
|
+
'displayPopupFooter': undefined,
|
|
67
|
+
'onLoadPanel': String,
|
|
68
|
+
'defaultView': String,
|
|
69
|
+
'name': String,
|
|
70
|
+
'description': String,
|
|
71
|
+
'licence': undefined,
|
|
72
|
+
'tilelayer': undefined,
|
|
73
|
+
'overlay': undefined,
|
|
74
|
+
'limitBounds': undefined,
|
|
75
|
+
'color': String,
|
|
76
|
+
'iconClass': String,
|
|
77
|
+
'iconUrl': String,
|
|
78
|
+
'smoothFactor': undefined,
|
|
79
|
+
'iconOpacity': undefined,
|
|
80
|
+
'opacity': undefined,
|
|
81
|
+
'weight': undefined,
|
|
82
|
+
'fill': undefined,
|
|
83
|
+
'fillColor': undefined,
|
|
84
|
+
'fillOpacity': undefined,
|
|
85
|
+
'dashArray': undefined,
|
|
86
|
+
'popupShape': String,
|
|
87
|
+
'popupTemplate': String,
|
|
88
|
+
'popupContentTemplate': String,
|
|
89
|
+
'zoomTo': undefined,
|
|
90
|
+
'captionBar': Boolean,
|
|
91
|
+
'captionMenus': Boolean,
|
|
92
|
+
'slideshow': undefined,
|
|
93
|
+
'sortKey': undefined,
|
|
94
|
+
'labelKey': undefined,
|
|
95
|
+
'filterKey': undefined,
|
|
96
|
+
'facetKey': undefined,
|
|
97
|
+
'slugKey': undefined,
|
|
98
|
+
'showLabel': undefined,
|
|
99
|
+
'labelDirection': undefined,
|
|
100
|
+
'labelInteractive': undefined,
|
|
101
|
+
'outlinkTarget': undefined,
|
|
102
|
+
'shortCredit': undefined,
|
|
103
|
+
'longCredit': undefined,
|
|
104
|
+
'permanentCredit': undefined,
|
|
105
|
+
'permanentCreditBackground': undefined,
|
|
106
|
+
'zoomControl': 'NullableBoolean',
|
|
107
|
+
'datalayersControl': 'NullableBoolean',
|
|
108
|
+
'searchControl': 'NullableBoolean',
|
|
109
|
+
'locateControl': 'NullableBoolean',
|
|
110
|
+
'fullscreenControl': 'NullableBoolean',
|
|
111
|
+
'editinosmControl': 'NullableBoolean',
|
|
112
|
+
'embedControl': 'NullableBoolean',
|
|
113
|
+
'measureControl': 'NullableBoolean',
|
|
114
|
+
'tilelayersControl': 'NullableBoolean',
|
|
115
|
+
'starControl': 'NullableBoolean',
|
|
116
|
+
'easing': undefined,
|
|
117
|
+
},
|
|
71
118
|
|
|
72
119
|
initialize: function (el, geojson) {
|
|
73
120
|
// Locale name (pt_PT, en_US…)
|
|
@@ -89,18 +136,19 @@ L.U.Map.include({
|
|
|
89
136
|
? geojson.properties.fullscreenControl
|
|
90
137
|
: true
|
|
91
138
|
geojson.properties.fullscreenControl = false
|
|
92
|
-
|
|
139
|
+
this.setOptionsFromQueryString(geojson.properties)
|
|
93
140
|
|
|
94
141
|
L.Map.prototype.initialize.call(this, el, geojson.properties)
|
|
95
142
|
|
|
96
143
|
// After calling parent initialize, as we are doing initCenter our-selves
|
|
97
144
|
if (geojson.geometry) this.options.center = this.latLng(geojson.geometry)
|
|
98
|
-
this.urls = new
|
|
145
|
+
this.urls = new U.URLs(this.options.urls)
|
|
99
146
|
|
|
100
|
-
this.ui = new
|
|
101
|
-
this.
|
|
102
|
-
this.
|
|
103
|
-
this.
|
|
147
|
+
this.ui = new U.UI(this._container)
|
|
148
|
+
this.ui.on('dataloading', (e) => this.fire('dataloading', e))
|
|
149
|
+
this.ui.on('dataload', (e) => this.fire('dataload', e))
|
|
150
|
+
this.server = new U.ServerRequest(this.ui)
|
|
151
|
+
this.request = new U.Request(this.ui)
|
|
104
152
|
|
|
105
153
|
this.initLoader()
|
|
106
154
|
this.name = this.options.name
|
|
@@ -108,27 +156,10 @@ L.U.Map.include({
|
|
|
108
156
|
this.demoTileInfos = this.options.demoTileInfos
|
|
109
157
|
this.options.zoomControl = zoomControl
|
|
110
158
|
this.options.fullscreenControl = fullscreenControl
|
|
111
|
-
L.Util.setBooleanFromQueryString(this.options, 'moreControl')
|
|
112
|
-
L.Util.setBooleanFromQueryString(this.options, 'scaleControl')
|
|
113
|
-
L.Util.setBooleanFromQueryString(this.options, 'miniMap')
|
|
114
|
-
L.Util.setFromQueryString(this.options, 'editMode')
|
|
115
|
-
L.Util.setBooleanFromQueryString(this.options, 'displayDataBrowserOnLoad')
|
|
116
|
-
L.Util.setBooleanFromQueryString(this.options, 'displayCaptionOnLoad')
|
|
117
|
-
L.Util.setBooleanFromQueryString(this.options, 'captionBar')
|
|
118
|
-
L.Util.setBooleanFromQueryString(this.options, 'captionMenus')
|
|
119
|
-
for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
|
|
120
|
-
L.Util.setNullableBooleanFromQueryString(
|
|
121
|
-
this.options,
|
|
122
|
-
`${this.HIDDABLE_CONTROLS[i]}Control`
|
|
123
|
-
)
|
|
124
|
-
}
|
|
125
159
|
this.datalayersOnLoad = L.Util.queryString('datalayers')
|
|
126
|
-
this.
|
|
127
|
-
'onLoadPanel',
|
|
128
|
-
this.options.onLoadPanel
|
|
129
|
-
)
|
|
130
|
-
if (this.datalayersOnLoad)
|
|
160
|
+
if (this.datalayersOnLoad) {
|
|
131
161
|
this.datalayersOnLoad = this.datalayersOnLoad.toString().split(',')
|
|
162
|
+
}
|
|
132
163
|
|
|
133
164
|
if (L.Browser.ielt9) this.options.editMode = 'disabled' // TODO include ie9
|
|
134
165
|
|
|
@@ -169,7 +200,7 @@ L.U.Map.include({
|
|
|
169
200
|
this.facets = {}
|
|
170
201
|
|
|
171
202
|
// Needed for actions labels
|
|
172
|
-
this.help = new
|
|
203
|
+
this.help = new U.Help(this)
|
|
173
204
|
|
|
174
205
|
if (this.options.hash) this.addHash()
|
|
175
206
|
this.initTileLayers()
|
|
@@ -178,7 +209,7 @@ L.U.Map.include({
|
|
|
178
209
|
// Needs locate control and hash to exist
|
|
179
210
|
this.initCenter()
|
|
180
211
|
this.handleLimitBounds()
|
|
181
|
-
this.
|
|
212
|
+
this.initDataLayers()
|
|
182
213
|
|
|
183
214
|
if (this.options.displayCaptionOnLoad) {
|
|
184
215
|
// Retrocompat
|
|
@@ -227,28 +258,33 @@ L.U.Map.include({
|
|
|
227
258
|
|
|
228
259
|
// Creation mode
|
|
229
260
|
if (!this.options.umap_id) {
|
|
230
|
-
this.
|
|
261
|
+
if (!this.options.preview) {
|
|
262
|
+
this.isDirty = true
|
|
263
|
+
this.enableEdit()
|
|
264
|
+
}
|
|
231
265
|
this._default_extent = true
|
|
232
266
|
this.options.name = L._('Untitled map')
|
|
233
|
-
|
|
234
|
-
const datalayer = this.createDataLayer()
|
|
235
|
-
datalayer.connectToMap()
|
|
236
|
-
this.enableEdit()
|
|
267
|
+
let data = L.Util.queryString('data', null)
|
|
237
268
|
let dataUrl = L.Util.queryString('dataUrl', null)
|
|
238
269
|
const dataFormat = L.Util.queryString('dataFormat', 'geojson')
|
|
239
270
|
if (dataUrl) {
|
|
240
271
|
dataUrl = decodeURIComponent(dataUrl)
|
|
241
272
|
dataUrl = this.localizeUrl(dataUrl)
|
|
242
273
|
dataUrl = this.proxyUrl(dataUrl)
|
|
274
|
+
const datalayer = this.createDataLayer()
|
|
243
275
|
datalayer.importFromUrl(dataUrl, dataFormat)
|
|
276
|
+
} else if (data) {
|
|
277
|
+
data = decodeURIComponent(data)
|
|
278
|
+
const datalayer = this.createDataLayer()
|
|
279
|
+
datalayer.importRaw(data, dataFormat)
|
|
244
280
|
}
|
|
245
281
|
}
|
|
246
282
|
|
|
247
|
-
this.slideshow = new
|
|
248
|
-
this.permissions = new
|
|
283
|
+
this.slideshow = new U.Slideshow(this, this.options.slideshow)
|
|
284
|
+
this.permissions = new U.MapPermissions(this)
|
|
249
285
|
this.initCaptionBar()
|
|
250
286
|
if (this.hasEditMode()) {
|
|
251
|
-
this.editTools = new
|
|
287
|
+
this.editTools = new U.Editable(this)
|
|
252
288
|
this.ui.on(
|
|
253
289
|
'panel:closed panel:open',
|
|
254
290
|
function () {
|
|
@@ -268,8 +304,6 @@ L.U.Map.include({
|
|
|
268
304
|
this.options.onLoadPanel === 'datafilters'
|
|
269
305
|
)
|
|
270
306
|
this.openFacet()
|
|
271
|
-
})
|
|
272
|
-
this.onceDataLoaded(function () {
|
|
273
307
|
const slug = L.Util.queryString('feature')
|
|
274
308
|
if (slug && this.features_index[slug]) this.features_index[slug].view()
|
|
275
309
|
if (L.Util.queryString('edit')) {
|
|
@@ -288,36 +322,61 @@ L.U.Map.include({
|
|
|
288
322
|
}
|
|
289
323
|
})
|
|
290
324
|
|
|
291
|
-
window.onbeforeunload = () => this.isDirty || null
|
|
325
|
+
window.onbeforeunload = () => this.editEnabled && this.isDirty || null
|
|
292
326
|
this.backup()
|
|
293
327
|
this.initContextMenu()
|
|
294
328
|
this.on('click contextmenu.show', this.closeInplaceToolbar)
|
|
295
329
|
},
|
|
296
330
|
|
|
331
|
+
setOptionsFromQueryString: function (options) {
|
|
332
|
+
// This is not an editable option
|
|
333
|
+
L.Util.setFromQueryString(options, 'editMode')
|
|
334
|
+
// FIXME retrocompat
|
|
335
|
+
L.Util.setBooleanFromQueryString(options, 'displayDataBrowserOnLoad')
|
|
336
|
+
L.Util.setBooleanFromQueryString(options, 'displayCaptionOnLoad')
|
|
337
|
+
for (const [key, type] of Object.entries(this.editableOptions)) {
|
|
338
|
+
switch (type) {
|
|
339
|
+
case Boolean:
|
|
340
|
+
L.Util.setBooleanFromQueryString(options, key)
|
|
341
|
+
break
|
|
342
|
+
case 'NullableBoolean':
|
|
343
|
+
L.Util.setNullableBooleanFromQueryString(options, key)
|
|
344
|
+
break
|
|
345
|
+
case String:
|
|
346
|
+
L.Util.setFromQueryString(options, key)
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
// Specific case for datalayersControl
|
|
350
|
+
// which accepts "expanded" value, on top of true/false/null
|
|
351
|
+
if (L.Util.queryString('datalayersControl') === 'expanded') {
|
|
352
|
+
L.Util.setFromQueryString(options, 'datalayersControl')
|
|
353
|
+
}
|
|
354
|
+
},
|
|
355
|
+
|
|
297
356
|
initControls: function () {
|
|
298
357
|
this.helpMenuActions = {}
|
|
299
358
|
this._controls = {}
|
|
300
359
|
|
|
301
360
|
if (this.hasEditMode() && !this.options.noControl) {
|
|
302
|
-
new
|
|
361
|
+
new U.EditControl(this).addTo(this)
|
|
303
362
|
|
|
304
|
-
new
|
|
363
|
+
new U.DrawToolbar({ map: this }).addTo(this)
|
|
305
364
|
|
|
306
365
|
const editActions = [
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
366
|
+
U.ImportAction,
|
|
367
|
+
U.EditPropertiesAction,
|
|
368
|
+
U.ManageDatalayersAction,
|
|
369
|
+
U.ChangeTileLayerAction,
|
|
370
|
+
U.UpdateExtentAction,
|
|
371
|
+
U.UpdatePermsAction,
|
|
313
372
|
]
|
|
314
|
-
new
|
|
373
|
+
new U.SettingsToolbar({ actions: editActions }).addTo(this)
|
|
315
374
|
}
|
|
316
375
|
this._controls.zoom = new L.Control.Zoom({
|
|
317
376
|
zoomInTitle: L._('Zoom in'),
|
|
318
377
|
zoomOutTitle: L._('Zoom out'),
|
|
319
378
|
})
|
|
320
|
-
this._controls.datalayers = new
|
|
379
|
+
this._controls.datalayers = new U.DataLayersControl(this)
|
|
321
380
|
this._controls.locate = L.control.locate({
|
|
322
381
|
strings: {
|
|
323
382
|
title: L._('Center map on your location'),
|
|
@@ -334,10 +393,10 @@ L.U.Map.include({
|
|
|
334
393
|
this._controls.fullscreen = new L.Control.Fullscreen({
|
|
335
394
|
title: { false: L._('View Fullscreen'), true: L._('Exit Fullscreen') },
|
|
336
395
|
})
|
|
337
|
-
this._controls.search = new
|
|
396
|
+
this._controls.search = new U.SearchControl()
|
|
338
397
|
this._controls.embed = new L.Control.Embed(this, this.options.embedOptions)
|
|
339
|
-
this._controls.tilelayersChooser = new
|
|
340
|
-
this._controls.star = new
|
|
398
|
+
this._controls.tilelayersChooser = new U.TileLayerChooser(this)
|
|
399
|
+
this._controls.star = new U.StarControl(this)
|
|
341
400
|
this._controls.editinosm = new L.Control.EditInOSM({
|
|
342
401
|
position: 'topleft',
|
|
343
402
|
widgetOptions: {
|
|
@@ -347,16 +406,16 @@ L.U.Map.include({
|
|
|
347
406
|
},
|
|
348
407
|
})
|
|
349
408
|
this._controls.measure = new L.MeasureControl().initHandler(this)
|
|
350
|
-
this._controls.more = new
|
|
409
|
+
this._controls.more = new U.MoreControls()
|
|
351
410
|
this._controls.scale = L.control.scale()
|
|
352
|
-
this._controls.permanentCredit = new
|
|
411
|
+
this._controls.permanentCredit = new U.PermanentCreditsControl(this)
|
|
353
412
|
if (this.options.scrollWheelZoom) this.scrollWheelZoom.enable()
|
|
354
413
|
else this.scrollWheelZoom.disable()
|
|
355
|
-
this.browser = new
|
|
356
|
-
this.importer = new
|
|
357
|
-
this.drop = new
|
|
358
|
-
this.share = new
|
|
359
|
-
this._controls.tilelayers = new
|
|
414
|
+
this.browser = new U.Browser(this)
|
|
415
|
+
this.importer = new U.Importer(this)
|
|
416
|
+
this.drop = new U.DropControl(this)
|
|
417
|
+
this.share = new U.Share(this)
|
|
418
|
+
this._controls.tilelayers = new U.TileLayerControl(this)
|
|
360
419
|
this._controls.tilelayers.setLayers()
|
|
361
420
|
|
|
362
421
|
this.renderControls()
|
|
@@ -379,7 +438,7 @@ L.U.Map.include({
|
|
|
379
438
|
}
|
|
380
439
|
if (this.options.noControl) return
|
|
381
440
|
|
|
382
|
-
this._controls.attribution = new
|
|
441
|
+
this._controls.attribution = new U.AttributionControl().addTo(this)
|
|
383
442
|
if (this.options.miniMap && !this.options.noControl) {
|
|
384
443
|
this.whenReady(function () {
|
|
385
444
|
if (this.selected_tilelayer) {
|
|
@@ -414,56 +473,22 @@ L.U.Map.include({
|
|
|
414
473
|
if (this.options.scaleControl) this._controls.scale.addTo(this)
|
|
415
474
|
},
|
|
416
475
|
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
476
|
+
initDataLayers: async function (datalayers) {
|
|
477
|
+
datalayers = datalayers || this.options.datalayers
|
|
478
|
+
for (const options of datalayers) {
|
|
479
|
+
this.createDataLayer(options)
|
|
420
480
|
}
|
|
421
|
-
this.
|
|
481
|
+
await this.loadDataLayers()
|
|
422
482
|
},
|
|
423
483
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
dataToload = total
|
|
430
|
-
let datalayer
|
|
431
|
-
const loaded = () => {
|
|
432
|
-
this.datalayersLoaded = true
|
|
433
|
-
this.fire('datalayersloaded')
|
|
434
|
-
}
|
|
435
|
-
const decrementToLoad = () => {
|
|
436
|
-
toload--
|
|
437
|
-
if (toload === 0) loaded()
|
|
438
|
-
}
|
|
439
|
-
const dataLoaded = () => {
|
|
440
|
-
this.dataLoaded = true
|
|
441
|
-
this.fire('dataloaded')
|
|
442
|
-
}
|
|
443
|
-
const decrementDataToLoad = () => {
|
|
444
|
-
dataToload--
|
|
445
|
-
if (dataToload === 0) dataLoaded()
|
|
446
|
-
}
|
|
447
|
-
this.eachDataLayer(function (datalayer) {
|
|
448
|
-
if (force && !datalayer.hasDataLoaded()) {
|
|
449
|
-
datalayer.show()
|
|
450
|
-
}
|
|
451
|
-
if (datalayer.showAtLoad() || force) {
|
|
452
|
-
datalayer.onceLoaded(decrementToLoad)
|
|
453
|
-
} else {
|
|
454
|
-
decrementToLoad()
|
|
455
|
-
}
|
|
456
|
-
if (datalayer.showAtLoad() || force) {
|
|
457
|
-
datalayer.onceDataLoaded(decrementDataToLoad)
|
|
458
|
-
} else {
|
|
459
|
-
decrementDataToLoad({ sourceTarget: datalayer })
|
|
460
|
-
}
|
|
461
|
-
})
|
|
462
|
-
if (total === 0) {
|
|
463
|
-
// no datalayer
|
|
464
|
-
loaded()
|
|
465
|
-
dataLoaded()
|
|
484
|
+
loadDataLayers: async function () {
|
|
485
|
+
this.datalayersLoaded = true
|
|
486
|
+
this.fire('datalayersloaded')
|
|
487
|
+
for (const datalayer of Object.values(this.datalayers)) {
|
|
488
|
+
if (datalayer.showAtLoad()) await datalayer.show()
|
|
466
489
|
}
|
|
490
|
+
this.dataloaded = true
|
|
491
|
+
this.fire('dataloaded')
|
|
467
492
|
},
|
|
468
493
|
|
|
469
494
|
indexDatalayers: function () {
|
|
@@ -496,7 +521,7 @@ L.U.Map.include({
|
|
|
496
521
|
|
|
497
522
|
onceDataLoaded: function (callback, context) {
|
|
498
523
|
// Once datalayers **data** have been loaded
|
|
499
|
-
if (this.
|
|
524
|
+
if (this.dataloaded) {
|
|
500
525
|
callback.call(context || this, this)
|
|
501
526
|
} else {
|
|
502
527
|
this.once('dataloaded', callback, context)
|
|
@@ -527,10 +552,10 @@ L.U.Map.include({
|
|
|
527
552
|
modifierKey = e.ctrlKey || e.metaKey
|
|
528
553
|
|
|
529
554
|
/* Generic shortcuts */
|
|
530
|
-
if (key ===
|
|
555
|
+
if (key === U.Keys.F && modifierKey) {
|
|
531
556
|
L.DomEvent.stop(e)
|
|
532
557
|
this.search()
|
|
533
|
-
} else if (e.keyCode ===
|
|
558
|
+
} else if (e.keyCode === U.Keys.ESC) {
|
|
534
559
|
if (this.help.visible()) this.help.hide()
|
|
535
560
|
else this.ui.closePanel()
|
|
536
561
|
}
|
|
@@ -538,11 +563,11 @@ L.U.Map.include({
|
|
|
538
563
|
if (!this.hasEditMode()) return
|
|
539
564
|
|
|
540
565
|
/* Edit mode only shortcuts */
|
|
541
|
-
if (key ===
|
|
566
|
+
if (key === U.Keys.E && modifierKey && !this.editEnabled) {
|
|
542
567
|
L.DomEvent.stop(e)
|
|
543
568
|
this.enableEdit()
|
|
544
569
|
} else if (
|
|
545
|
-
key ===
|
|
570
|
+
key === U.Keys.E &&
|
|
546
571
|
modifierKey &&
|
|
547
572
|
this.editEnabled &&
|
|
548
573
|
!this.isDirty
|
|
@@ -551,41 +576,41 @@ L.U.Map.include({
|
|
|
551
576
|
this.disableEdit()
|
|
552
577
|
this.ui.closePanel()
|
|
553
578
|
}
|
|
554
|
-
if (key ===
|
|
579
|
+
if (key === U.Keys.S && modifierKey) {
|
|
555
580
|
L.DomEvent.stop(e)
|
|
556
581
|
if (this.isDirty) {
|
|
557
582
|
this.save()
|
|
558
583
|
}
|
|
559
584
|
}
|
|
560
|
-
if (key ===
|
|
585
|
+
if (key === U.Keys.Z && modifierKey && this.isDirty) {
|
|
561
586
|
L.DomEvent.stop(e)
|
|
562
587
|
this.askForReset()
|
|
563
588
|
}
|
|
564
|
-
if (key ===
|
|
589
|
+
if (key === U.Keys.M && modifierKey && this.editEnabled) {
|
|
565
590
|
L.DomEvent.stop(e)
|
|
566
591
|
this.editTools.startMarker()
|
|
567
592
|
}
|
|
568
|
-
if (key ===
|
|
593
|
+
if (key === U.Keys.P && modifierKey && this.editEnabled) {
|
|
569
594
|
L.DomEvent.stop(e)
|
|
570
595
|
this.editTools.startPolygon()
|
|
571
596
|
}
|
|
572
|
-
if (key ===
|
|
597
|
+
if (key === U.Keys.L && modifierKey && this.editEnabled) {
|
|
573
598
|
L.DomEvent.stop(e)
|
|
574
599
|
this.editTools.startPolyline()
|
|
575
600
|
}
|
|
576
|
-
if (key ===
|
|
601
|
+
if (key === U.Keys.I && modifierKey && this.editEnabled) {
|
|
577
602
|
L.DomEvent.stop(e)
|
|
578
603
|
this.importer.open()
|
|
579
604
|
}
|
|
580
|
-
if (key ===
|
|
605
|
+
if (key === U.Keys.O && modifierKey && this.editEnabled) {
|
|
581
606
|
L.DomEvent.stop(e)
|
|
582
607
|
this.importer.openFiles()
|
|
583
608
|
}
|
|
584
|
-
if (key ===
|
|
609
|
+
if (key === U.Keys.H && modifierKey && this.editEnabled) {
|
|
585
610
|
L.DomEvent.stop(e)
|
|
586
611
|
this.help.show('edit')
|
|
587
612
|
}
|
|
588
|
-
if (e.keyCode ===
|
|
613
|
+
if (e.keyCode === U.Keys.ESC) {
|
|
589
614
|
if (this.editEnabled && this.editTools.drawing()) {
|
|
590
615
|
this.editTools.stopDrawing()
|
|
591
616
|
}
|
|
@@ -796,7 +821,7 @@ L.U.Map.include({
|
|
|
796
821
|
datalayer = datalayer || {
|
|
797
822
|
name: `${L._('Layer')} ${this.datalayers_index.length + 1}`,
|
|
798
823
|
}
|
|
799
|
-
return new
|
|
824
|
+
return new U.DataLayer(this, datalayer)
|
|
800
825
|
},
|
|
801
826
|
|
|
802
827
|
getDefaultOption: function (option) {
|
|
@@ -830,7 +855,10 @@ L.U.Map.include({
|
|
|
830
855
|
self.isDirty = true
|
|
831
856
|
}
|
|
832
857
|
if (this._controls.tilelayersChooser)
|
|
833
|
-
this._controls.tilelayersChooser.openSwitcher({
|
|
858
|
+
this._controls.tilelayersChooser.openSwitcher({
|
|
859
|
+
callback: callback,
|
|
860
|
+
className: 'dark',
|
|
861
|
+
})
|
|
834
862
|
},
|
|
835
863
|
|
|
836
864
|
manageDatalayers: function () {
|
|
@@ -881,8 +909,7 @@ L.U.Map.include({
|
|
|
881
909
|
|
|
882
910
|
let mustReindex = false
|
|
883
911
|
|
|
884
|
-
for (
|
|
885
|
-
const option = this.editableOptions[i]
|
|
912
|
+
for (const option of Object.keys(this.editableOptions)) {
|
|
886
913
|
if (typeof importedData.properties[option] !== 'undefined') {
|
|
887
914
|
this.options[option] = importedData.properties[option]
|
|
888
915
|
if (option === 'sortKey') mustReindex = true
|
|
@@ -1009,76 +1036,17 @@ L.U.Map.include({
|
|
|
1009
1036
|
else this.fire('saved')
|
|
1010
1037
|
},
|
|
1011
1038
|
|
|
1012
|
-
editableOptions: [
|
|
1013
|
-
'zoom',
|
|
1014
|
-
'scrollWheelZoom',
|
|
1015
|
-
'scaleControl',
|
|
1016
|
-
'moreControl',
|
|
1017
|
-
'miniMap',
|
|
1018
|
-
'displayPopupFooter',
|
|
1019
|
-
'onLoadPanel',
|
|
1020
|
-
'defaultView',
|
|
1021
|
-
'name',
|
|
1022
|
-
'description',
|
|
1023
|
-
'licence',
|
|
1024
|
-
'tilelayer',
|
|
1025
|
-
'overlay',
|
|
1026
|
-
'limitBounds',
|
|
1027
|
-
'color',
|
|
1028
|
-
'iconClass',
|
|
1029
|
-
'iconUrl',
|
|
1030
|
-
'smoothFactor',
|
|
1031
|
-
'iconOpacity',
|
|
1032
|
-
'opacity',
|
|
1033
|
-
'weight',
|
|
1034
|
-
'fill',
|
|
1035
|
-
'fillColor',
|
|
1036
|
-
'fillOpacity',
|
|
1037
|
-
'dashArray',
|
|
1038
|
-
'popupShape',
|
|
1039
|
-
'popupTemplate',
|
|
1040
|
-
'popupContentTemplate',
|
|
1041
|
-
'zoomTo',
|
|
1042
|
-
'captionBar',
|
|
1043
|
-
'captionMenus',
|
|
1044
|
-
'slideshow',
|
|
1045
|
-
'sortKey',
|
|
1046
|
-
'labelKey',
|
|
1047
|
-
'filterKey',
|
|
1048
|
-
'facetKey',
|
|
1049
|
-
'slugKey',
|
|
1050
|
-
'showLabel',
|
|
1051
|
-
'labelDirection',
|
|
1052
|
-
'labelInteractive',
|
|
1053
|
-
'outlinkTarget',
|
|
1054
|
-
'shortCredit',
|
|
1055
|
-
'longCredit',
|
|
1056
|
-
'permanentCredit',
|
|
1057
|
-
'permanentCreditBackground',
|
|
1058
|
-
'zoomControl',
|
|
1059
|
-
'datalayersControl',
|
|
1060
|
-
'searchControl',
|
|
1061
|
-
'locateControl',
|
|
1062
|
-
'fullscreenControl',
|
|
1063
|
-
'editinosmControl',
|
|
1064
|
-
'embedControl',
|
|
1065
|
-
'measureControl',
|
|
1066
|
-
'tilelayersControl',
|
|
1067
|
-
'starControl',
|
|
1068
|
-
'easing',
|
|
1069
|
-
],
|
|
1070
|
-
|
|
1071
1039
|
exportOptions: function () {
|
|
1072
1040
|
const properties = {}
|
|
1073
|
-
for (
|
|
1074
|
-
if (typeof this.options[
|
|
1075
|
-
properties[
|
|
1041
|
+
for (const option of Object.keys(this.editableOptions)) {
|
|
1042
|
+
if (typeof this.options[option] !== 'undefined') {
|
|
1043
|
+
properties[option] = this.options[option]
|
|
1076
1044
|
}
|
|
1077
1045
|
}
|
|
1078
1046
|
return properties
|
|
1079
1047
|
},
|
|
1080
1048
|
|
|
1081
|
-
saveSelf: function () {
|
|
1049
|
+
saveSelf: async function () {
|
|
1082
1050
|
const geojson = {
|
|
1083
1051
|
type: 'Feature',
|
|
1084
1052
|
geometry: this.geometry(),
|
|
@@ -1088,64 +1056,62 @@ L.U.Map.include({
|
|
|
1088
1056
|
formData.append('name', this.options.name)
|
|
1089
1057
|
formData.append('center', JSON.stringify(this.geometry()))
|
|
1090
1058
|
formData.append('settings', JSON.stringify(geojson))
|
|
1091
|
-
this.
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
})
|
|
1128
|
-
},
|
|
1129
|
-
callbackContext: this,
|
|
1059
|
+
const uri = this.urls.get('map_save', { map_id: this.options.umap_id })
|
|
1060
|
+
const [data, response, error] = await this.server.post(uri, {}, formData)
|
|
1061
|
+
if (!error) {
|
|
1062
|
+
let duration = 3000,
|
|
1063
|
+
alert = { content: L._('Map has been saved!'), level: 'info' }
|
|
1064
|
+
if (!this.options.umap_id) {
|
|
1065
|
+
alert.content = L._('Congratulations, your map has been created!')
|
|
1066
|
+
this.options.umap_id = data.id
|
|
1067
|
+
this.permissions.setOptions(data.permissions)
|
|
1068
|
+
this.permissions.commit()
|
|
1069
|
+
if (
|
|
1070
|
+
data.permissions &&
|
|
1071
|
+
data.permissions.anonymous_edit_url &&
|
|
1072
|
+
this.options.urls.map_send_edit_link
|
|
1073
|
+
) {
|
|
1074
|
+
alert.duration = Infinity
|
|
1075
|
+
alert.content =
|
|
1076
|
+
L._(
|
|
1077
|
+
'Your map has been created! As you are not logged in, here is your secret link to edit the map, please keep it safe:'
|
|
1078
|
+
) + `<br>${data.permissions.anonymous_edit_url}`
|
|
1079
|
+
|
|
1080
|
+
alert.actions = [
|
|
1081
|
+
{
|
|
1082
|
+
label: L._('Send me the link'),
|
|
1083
|
+
input: L._('Email'),
|
|
1084
|
+
callback: this.sendEditLink,
|
|
1085
|
+
callbackContext: this,
|
|
1086
|
+
},
|
|
1087
|
+
{
|
|
1088
|
+
label: L._('Copy link'),
|
|
1089
|
+
callback: () => {
|
|
1090
|
+
L.Util.copyToClipboard(data.permissions.anonymous_edit_url)
|
|
1091
|
+
this.ui.alert({
|
|
1092
|
+
content: L._('Secret edit link copied to clipboard!'),
|
|
1093
|
+
level: 'info',
|
|
1094
|
+
})
|
|
1130
1095
|
},
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
// Do not override local changes to permissions,
|
|
1135
|
-
// but update in case some other editors changed them in the meantime.
|
|
1136
|
-
this.permissions.setOptions(data.permissions)
|
|
1137
|
-
this.permissions.commit()
|
|
1096
|
+
callbackContext: this,
|
|
1097
|
+
},
|
|
1098
|
+
]
|
|
1138
1099
|
}
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1100
|
+
} else if (!this.permissions.isDirty) {
|
|
1101
|
+
// Do not override local changes to permissions,
|
|
1102
|
+
// but update in case some other editors changed them in the meantime.
|
|
1103
|
+
this.permissions.setOptions(data.permissions)
|
|
1104
|
+
this.permissions.commit()
|
|
1105
|
+
}
|
|
1106
|
+
// Update URL in case the name has changed.
|
|
1107
|
+
if (history && history.pushState)
|
|
1108
|
+
history.pushState({}, this.options.name, data.url)
|
|
1109
|
+
else window.location = data.url
|
|
1110
|
+
alert.content = data.info || alert.content
|
|
1111
|
+
this.once('saved', () => this.ui.alert(alert))
|
|
1112
|
+
this.ui.closePanel()
|
|
1113
|
+
this.permissions.save()
|
|
1114
|
+
}
|
|
1149
1115
|
},
|
|
1150
1116
|
|
|
1151
1117
|
save: function () {
|
|
@@ -1220,13 +1186,13 @@ L.U.Map.include({
|
|
|
1220
1186
|
if (
|
|
1221
1187
|
datalayer &&
|
|
1222
1188
|
!datalayer.isDataReadOnly() &&
|
|
1223
|
-
datalayer.
|
|
1189
|
+
datalayer.isBrowsable() &&
|
|
1224
1190
|
datalayer.isVisible()
|
|
1225
1191
|
) {
|
|
1226
1192
|
return datalayer
|
|
1227
1193
|
}
|
|
1228
1194
|
datalayer = this.findDataLayer((datalayer) => {
|
|
1229
|
-
if (!datalayer.isDataReadOnly() && datalayer.
|
|
1195
|
+
if (!datalayer.isDataReadOnly() && datalayer.isBrowsable()) {
|
|
1230
1196
|
fallback = datalayer
|
|
1231
1197
|
if (datalayer.isVisible()) return true
|
|
1232
1198
|
}
|
|
@@ -1234,7 +1200,7 @@ L.U.Map.include({
|
|
|
1234
1200
|
if (datalayer) return datalayer
|
|
1235
1201
|
if (fallback) {
|
|
1236
1202
|
// No datalayer visible, let's force one
|
|
1237
|
-
|
|
1203
|
+
fallback.show()
|
|
1238
1204
|
return fallback
|
|
1239
1205
|
}
|
|
1240
1206
|
return this.createDataLayer()
|
|
@@ -1260,7 +1226,7 @@ L.U.Map.include({
|
|
|
1260
1226
|
'options.captionBar',
|
|
1261
1227
|
'options.captionMenus',
|
|
1262
1228
|
])
|
|
1263
|
-
builder = new
|
|
1229
|
+
builder = new U.FormBuilder(this, UIFields, {
|
|
1264
1230
|
callback: function () {
|
|
1265
1231
|
this.renderControls()
|
|
1266
1232
|
this.initCaptionBar()
|
|
@@ -1289,7 +1255,7 @@ L.U.Map.include({
|
|
|
1289
1255
|
'options.dashArray',
|
|
1290
1256
|
]
|
|
1291
1257
|
|
|
1292
|
-
builder = new
|
|
1258
|
+
builder = new U.FormBuilder(this, shapeOptions, {
|
|
1293
1259
|
callback: function (e) {
|
|
1294
1260
|
if (this._controls.miniMap) this.renderControls()
|
|
1295
1261
|
this.eachVisibleDataLayer((datalayer) => {
|
|
@@ -1349,7 +1315,7 @@ L.U.Map.include({
|
|
|
1349
1315
|
],
|
|
1350
1316
|
]
|
|
1351
1317
|
|
|
1352
|
-
builder = new
|
|
1318
|
+
builder = new U.FormBuilder(this, optionsFields, {
|
|
1353
1319
|
callback: function (e) {
|
|
1354
1320
|
this.initCaptionBar()
|
|
1355
1321
|
if (e.helper.field === 'options.sortKey') {
|
|
@@ -1374,7 +1340,7 @@ L.U.Map.include({
|
|
|
1374
1340
|
'options.labelInteractive',
|
|
1375
1341
|
'options.outlinkTarget',
|
|
1376
1342
|
]
|
|
1377
|
-
builder = new
|
|
1343
|
+
builder = new U.FormBuilder(this, popupFields, {
|
|
1378
1344
|
callback: function (e) {
|
|
1379
1345
|
if (
|
|
1380
1346
|
e.helper.field === 'options.popupTemplate' ||
|
|
@@ -1441,7 +1407,7 @@ L.U.Map.include({
|
|
|
1441
1407
|
container,
|
|
1442
1408
|
L._('Custom background')
|
|
1443
1409
|
)
|
|
1444
|
-
builder = new
|
|
1410
|
+
builder = new U.FormBuilder(this, tilelayerFields, {
|
|
1445
1411
|
callback: this.initTileLayers,
|
|
1446
1412
|
callbackContext: this,
|
|
1447
1413
|
})
|
|
@@ -1492,7 +1458,7 @@ L.U.Map.include({
|
|
|
1492
1458
|
['options.overlay.tms', { handler: 'Switch', label: L._('TMS format') }],
|
|
1493
1459
|
]
|
|
1494
1460
|
const overlay = L.DomUtil.createFieldset(container, L._('Custom overlay'))
|
|
1495
|
-
builder = new
|
|
1461
|
+
builder = new U.FormBuilder(this, overlayFields, {
|
|
1496
1462
|
callback: this.initTileLayers,
|
|
1497
1463
|
callbackContext: this,
|
|
1498
1464
|
})
|
|
@@ -1522,7 +1488,7 @@ L.U.Map.include({
|
|
|
1522
1488
|
{ handler: 'BlurFloatInput', placeholder: L._('max East') },
|
|
1523
1489
|
],
|
|
1524
1490
|
]
|
|
1525
|
-
const boundsBuilder = new
|
|
1491
|
+
const boundsBuilder = new U.FormBuilder(this, boundsFields, {
|
|
1526
1492
|
callback: this.handleLimitBounds,
|
|
1527
1493
|
callbackContext: this,
|
|
1528
1494
|
})
|
|
@@ -1588,7 +1554,7 @@ L.U.Map.include({
|
|
|
1588
1554
|
this.slideshow.setOptions(this.options.slideshow)
|
|
1589
1555
|
this.renderControls()
|
|
1590
1556
|
}
|
|
1591
|
-
const slideshowBuilder = new
|
|
1557
|
+
const slideshowBuilder = new U.FormBuilder(this, slideshowFields, {
|
|
1592
1558
|
callback: slideshowHandler,
|
|
1593
1559
|
callbackContext: this,
|
|
1594
1560
|
})
|
|
@@ -1628,7 +1594,7 @@ L.U.Map.include({
|
|
|
1628
1594
|
{ handler: 'Switch', label: L._('Permanent credits background') },
|
|
1629
1595
|
],
|
|
1630
1596
|
]
|
|
1631
|
-
const creditsBuilder = new
|
|
1597
|
+
const creditsBuilder = new U.FormBuilder(this, creditsFields, {
|
|
1632
1598
|
callback: this.renderControls,
|
|
1633
1599
|
callbackContext: this,
|
|
1634
1600
|
})
|
|
@@ -1684,7 +1650,7 @@ L.U.Map.include({
|
|
|
1684
1650
|
metadataFields = ['options.name', 'options.description'],
|
|
1685
1651
|
title = L.DomUtil.create('h3', '', container)
|
|
1686
1652
|
title.textContent = L._('Edit map properties')
|
|
1687
|
-
const builder = new
|
|
1653
|
+
const builder = new U.FormBuilder(this, metadataFields)
|
|
1688
1654
|
const form = builder.build()
|
|
1689
1655
|
container.appendChild(form)
|
|
1690
1656
|
this._editControls(container)
|
|
@@ -1788,19 +1754,21 @@ L.U.Map.include({
|
|
|
1788
1754
|
return this.editTools.startPolygon()
|
|
1789
1755
|
},
|
|
1790
1756
|
|
|
1791
|
-
del: function () {
|
|
1757
|
+
del: async function () {
|
|
1792
1758
|
if (confirm(L._('Are you sure you want to delete this map?'))) {
|
|
1793
1759
|
const url = this.urls.get('map_delete', { map_id: this.options.umap_id })
|
|
1794
|
-
this.post(url)
|
|
1760
|
+
const [data, response, error] = await this.server.post(url)
|
|
1761
|
+
if (data.redirect) window.location = data.redirect
|
|
1795
1762
|
}
|
|
1796
1763
|
},
|
|
1797
1764
|
|
|
1798
|
-
clone: function () {
|
|
1765
|
+
clone: async function () {
|
|
1799
1766
|
if (
|
|
1800
1767
|
confirm(L._('Are you sure you want to clone this map and all its datalayers?'))
|
|
1801
1768
|
) {
|
|
1802
1769
|
const url = this.urls.get('map_clone', { map_id: this.options.umap_id })
|
|
1803
|
-
this.post(url)
|
|
1770
|
+
const [data, response, error] = await this.server.post(url)
|
|
1771
|
+
if (data.redirect) window.location = data.redirect
|
|
1804
1772
|
}
|
|
1805
1773
|
},
|
|
1806
1774
|
|
|
@@ -1815,25 +1783,8 @@ L.U.Map.include({
|
|
|
1815
1783
|
this.loader.onAdd(this)
|
|
1816
1784
|
},
|
|
1817
1785
|
|
|
1818
|
-
post: function (url, options) {
|
|
1819
|
-
options = options || {}
|
|
1820
|
-
options.listener = this
|
|
1821
|
-
this.xhr.post(url, options)
|
|
1822
|
-
},
|
|
1823
|
-
|
|
1824
|
-
get: function (url, options) {
|
|
1825
|
-
options = options || {}
|
|
1826
|
-
options.listener = this
|
|
1827
|
-
this.xhr.get(url, options)
|
|
1828
|
-
},
|
|
1829
|
-
|
|
1830
|
-
ajax: function (options) {
|
|
1831
|
-
options.listener = this
|
|
1832
|
-
this.xhr._ajax(options)
|
|
1833
|
-
},
|
|
1834
|
-
|
|
1835
1786
|
initContextMenu: function () {
|
|
1836
|
-
this.contextmenu = new
|
|
1787
|
+
this.contextmenu = new U.ContextMenu(this)
|
|
1837
1788
|
this.contextmenu.enable()
|
|
1838
1789
|
},
|
|
1839
1790
|
|