umap-project 1.14.0a1__py3-none-any.whl → 1.14.0a2__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.

Files changed (182) hide show
  1. umap/__init__.py +1 -1
  2. umap/static/.gitignore +0 -0
  3. umap/static/umap/base.css +994 -0
  4. umap/static/umap/bitbucket.png +0 -0
  5. umap/static/umap/content.css +395 -0
  6. umap/static/umap/favicons/apple-touch-icon.png +0 -0
  7. umap/static/umap/favicons/favicon.ico +0 -0
  8. umap/static/umap/favicons/icon-192.png +0 -0
  9. umap/static/umap/favicons/icon-512.png +0 -0
  10. umap/static/umap/favicons/icon.svg +5 -0
  11. umap/static/umap/font/FiraSans-Light.woff +0 -0
  12. umap/static/umap/font/FiraSans-Light.woff2 +0 -0
  13. umap/static/umap/font/FiraSans-LightItalic.woff +0 -0
  14. umap/static/umap/font/FiraSans-LightItalic.woff2 +0 -0
  15. umap/static/umap/font/FiraSans-SemiBold.woff +0 -0
  16. umap/static/umap/font/FiraSans-SemiBold.woff2 +0 -0
  17. umap/static/umap/font.css +33 -0
  18. umap/static/umap/github.png +0 -0
  19. umap/static/umap/img/16-white.svg +190 -0
  20. umap/static/umap/img/16.svg +182 -0
  21. umap/static/umap/img/24-white.svg +62 -0
  22. umap/static/umap/img/24.svg +90 -0
  23. umap/static/umap/img/edit.svg +7 -0
  24. umap/static/umap/img/icon-bg.png +0 -0
  25. umap/static/umap/img/logo.svg +4 -0
  26. umap/static/umap/img/logo_filigree.png +0 -0
  27. umap/static/umap/img/logo_small.svg +14 -0
  28. umap/static/umap/img/marker.png +0 -0
  29. umap/static/umap/img/opensource.svg +7 -0
  30. umap/static/umap/img/osm.svg +7 -0
  31. umap/static/umap/img/search.gif +0 -0
  32. umap/static/umap/img/source/16-white.svg +980 -0
  33. umap/static/umap/img/source/16.svg +201 -0
  34. umap/static/umap/img/source/24-white.svg +83 -0
  35. umap/static/umap/img/source/24.svg +110 -0
  36. umap/static/umap/js/components/fragment.js +13 -0
  37. umap/static/umap/js/modules/global.js +8 -0
  38. umap/static/umap/js/modules/urls.js +29 -0
  39. umap/static/umap/js/umap.autocomplete.js +336 -0
  40. umap/static/umap/js/umap.browser.js +148 -0
  41. umap/static/umap/js/umap.controls.js +1542 -0
  42. umap/static/umap/js/umap.core.js +851 -0
  43. umap/static/umap/js/umap.datalayer.permissions.js +72 -0
  44. umap/static/umap/js/umap.features.js +1216 -0
  45. umap/static/umap/js/umap.forms.js +1267 -0
  46. umap/static/umap/js/umap.icon.js +234 -0
  47. umap/static/umap/js/umap.importer.js +166 -0
  48. umap/static/umap/js/umap.js +2010 -0
  49. umap/static/umap/js/umap.layer.js +1636 -0
  50. umap/static/umap/js/umap.permissions.js +212 -0
  51. umap/static/umap/js/umap.popup.js +340 -0
  52. umap/static/umap/js/umap.share.js +254 -0
  53. umap/static/umap/js/umap.slideshow.js +165 -0
  54. umap/static/umap/js/umap.tableeditor.js +120 -0
  55. umap/static/umap/js/umap.ui.js +240 -0
  56. umap/static/umap/js/umap.xhr.js +304 -0
  57. umap/static/umap/locale/am_ET.js +447 -0
  58. umap/static/umap/locale/am_ET.json +445 -0
  59. umap/static/umap/locale/ar.js +447 -0
  60. umap/static/umap/locale/ar.json +445 -0
  61. umap/static/umap/locale/ast.js +447 -0
  62. umap/static/umap/locale/ast.json +445 -0
  63. umap/static/umap/locale/bg.js +447 -0
  64. umap/static/umap/locale/bg.json +445 -0
  65. umap/static/umap/locale/br.js +447 -0
  66. umap/static/umap/locale/br.json +445 -0
  67. umap/static/umap/locale/ca.js +447 -0
  68. umap/static/umap/locale/ca.json +445 -0
  69. umap/static/umap/locale/cs_CZ.js +447 -0
  70. umap/static/umap/locale/cs_CZ.json +445 -0
  71. umap/static/umap/locale/da.js +447 -0
  72. umap/static/umap/locale/da.json +445 -0
  73. umap/static/umap/locale/de.js +447 -0
  74. umap/static/umap/locale/de.json +445 -0
  75. umap/static/umap/locale/el.js +447 -0
  76. umap/static/umap/locale/el.json +445 -0
  77. umap/static/umap/locale/en.js +447 -0
  78. umap/static/umap/locale/en.json +445 -0
  79. umap/static/umap/locale/en_US.json +445 -0
  80. umap/static/umap/locale/es.js +447 -0
  81. umap/static/umap/locale/es.json +445 -0
  82. umap/static/umap/locale/et.js +447 -0
  83. umap/static/umap/locale/et.json +445 -0
  84. umap/static/umap/locale/eu.js +413 -0
  85. umap/static/umap/locale/eu.json +411 -0
  86. umap/static/umap/locale/fa_IR.js +447 -0
  87. umap/static/umap/locale/fa_IR.json +445 -0
  88. umap/static/umap/locale/fi.js +447 -0
  89. umap/static/umap/locale/fi.json +445 -0
  90. umap/static/umap/locale/fr.js +447 -0
  91. umap/static/umap/locale/fr.json +445 -0
  92. umap/static/umap/locale/gl.js +447 -0
  93. umap/static/umap/locale/gl.json +445 -0
  94. umap/static/umap/locale/he.js +447 -0
  95. umap/static/umap/locale/he.json +445 -0
  96. umap/static/umap/locale/hr.js +447 -0
  97. umap/static/umap/locale/hr.json +445 -0
  98. umap/static/umap/locale/hu.js +447 -0
  99. umap/static/umap/locale/hu.json +445 -0
  100. umap/static/umap/locale/id.js +447 -0
  101. umap/static/umap/locale/id.json +445 -0
  102. umap/static/umap/locale/is.js +447 -0
  103. umap/static/umap/locale/is.json +445 -0
  104. umap/static/umap/locale/it.js +447 -0
  105. umap/static/umap/locale/it.json +445 -0
  106. umap/static/umap/locale/ja.js +447 -0
  107. umap/static/umap/locale/ja.json +445 -0
  108. umap/static/umap/locale/ko.js +447 -0
  109. umap/static/umap/locale/ko.json +445 -0
  110. umap/static/umap/locale/lt.js +447 -0
  111. umap/static/umap/locale/lt.json +445 -0
  112. umap/static/umap/locale/ms.js +447 -0
  113. umap/static/umap/locale/ms.json +445 -0
  114. umap/static/umap/locale/nl.js +447 -0
  115. umap/static/umap/locale/nl.json +445 -0
  116. umap/static/umap/locale/no.js +447 -0
  117. umap/static/umap/locale/no.json +445 -0
  118. umap/static/umap/locale/pl.js +447 -0
  119. umap/static/umap/locale/pl.json +445 -0
  120. umap/static/umap/locale/pl_PL.json +445 -0
  121. umap/static/umap/locale/pt.js +447 -0
  122. umap/static/umap/locale/pt.json +445 -0
  123. umap/static/umap/locale/pt_BR.js +447 -0
  124. umap/static/umap/locale/pt_BR.json +445 -0
  125. umap/static/umap/locale/pt_PT.js +447 -0
  126. umap/static/umap/locale/pt_PT.json +445 -0
  127. umap/static/umap/locale/ro.js +447 -0
  128. umap/static/umap/locale/ro.json +445 -0
  129. umap/static/umap/locale/ru.js +447 -0
  130. umap/static/umap/locale/ru.json +445 -0
  131. umap/static/umap/locale/si.js +439 -0
  132. umap/static/umap/locale/si.json +437 -0
  133. umap/static/umap/locale/sk_SK.js +447 -0
  134. umap/static/umap/locale/sk_SK.json +445 -0
  135. umap/static/umap/locale/sl.js +447 -0
  136. umap/static/umap/locale/sl.json +445 -0
  137. umap/static/umap/locale/sr.js +447 -0
  138. umap/static/umap/locale/sr.json +445 -0
  139. umap/static/umap/locale/sv.js +447 -0
  140. umap/static/umap/locale/sv.json +445 -0
  141. umap/static/umap/locale/th_TH.js +447 -0
  142. umap/static/umap/locale/th_TH.json +445 -0
  143. umap/static/umap/locale/tr.js +447 -0
  144. umap/static/umap/locale/tr.json +445 -0
  145. umap/static/umap/locale/uk_UA.js +447 -0
  146. umap/static/umap/locale/uk_UA.json +445 -0
  147. umap/static/umap/locale/vi.js +447 -0
  148. umap/static/umap/locale/vi.json +445 -0
  149. umap/static/umap/locale/vi_VN.json +445 -0
  150. umap/static/umap/locale/zh.js +447 -0
  151. umap/static/umap/locale/zh.json +445 -0
  152. umap/static/umap/locale/zh_CN.json +445 -0
  153. umap/static/umap/locale/zh_TW.Big5.json +445 -0
  154. umap/static/umap/locale/zh_TW.js +447 -0
  155. umap/static/umap/locale/zh_TW.json +445 -0
  156. umap/static/umap/map.css +1843 -0
  157. umap/static/umap/nav.css +81 -0
  158. umap/static/umap/openstreetmap.png +0 -0
  159. umap/static/umap/test/.eslintrc +22 -0
  160. umap/static/umap/test/Choropleth.js +243 -0
  161. umap/static/umap/test/Controls.js +100 -0
  162. umap/static/umap/test/DataLayer.js +495 -0
  163. umap/static/umap/test/Feature.js +382 -0
  164. umap/static/umap/test/Map.Export.js +106 -0
  165. umap/static/umap/test/Map.Init.js +46 -0
  166. umap/static/umap/test/Map.js +342 -0
  167. umap/static/umap/test/Marker.js +122 -0
  168. umap/static/umap/test/Permissions.js +74 -0
  169. umap/static/umap/test/Polygon.js +367 -0
  170. umap/static/umap/test/Polyline.js +402 -0
  171. umap/static/umap/test/TableEditor.js +100 -0
  172. umap/static/umap/test/URLs.js +54 -0
  173. umap/static/umap/test/Util.js +549 -0
  174. umap/static/umap/test/_pre.js +460 -0
  175. umap/static/umap/test/index.html +135 -0
  176. umap/static/umap/theme.css +1 -0
  177. umap/static/umap/twitter.png +0 -0
  178. {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/METADATA +1 -1
  179. {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/RECORD +182 -6
  180. {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/WHEEL +0 -0
  181. {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/entry_points.txt +0 -0
  182. {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,234 @@
1
+ L.U.Icon = L.DivIcon.extend({
2
+ initialize: function (map, options) {
3
+ this.map = map
4
+ const default_options = {
5
+ iconSize: null, // Made in css
6
+ iconUrl: this.map.getDefaultOption('iconUrl'),
7
+ feature: null,
8
+ }
9
+ options = L.Util.extend({}, default_options, options)
10
+ L.Icon.prototype.initialize.call(this, options)
11
+ this.feature = this.options.feature
12
+ if (this.feature && this.feature.isReadOnly()) {
13
+ this.options.className += ' readonly'
14
+ }
15
+ },
16
+
17
+ _getIconUrl: function (name) {
18
+ let url
19
+ if (this.feature && this.feature._getIconUrl(name))
20
+ url = this.feature._getIconUrl(name)
21
+ else url = this.options[`${name}Url`]
22
+ return this.formatUrl(url, this.feature)
23
+ },
24
+
25
+ _getColor: function () {
26
+ let color
27
+ if (this.feature) color = this.feature.getDynamicOption('color')
28
+ else if (this.options.color) color = this.options.color
29
+ else color = this.map.getDefaultOption('color')
30
+ return color
31
+ },
32
+
33
+ _getOpacity: function () {
34
+ if (this.feature) return this.feature.getOption('iconOpacity')
35
+ return this.map.getDefaultOption('iconOpacity')
36
+ },
37
+
38
+ formatUrl: function (url, feature) {
39
+ return L.Util.greedyTemplate(url || '', feature ? feature.extendedProperties() : {})
40
+ },
41
+
42
+ onAdd: function () {},
43
+ })
44
+
45
+ L.U.Icon.Default = L.U.Icon.extend({
46
+ default_options: {
47
+ iconAnchor: new L.Point(16, 40),
48
+ popupAnchor: new L.Point(0, -40),
49
+ tooltipAnchor: new L.Point(16, -24),
50
+ className: 'umap-div-icon',
51
+ },
52
+
53
+ initialize: function (map, options) {
54
+ options = L.Util.extend({}, this.default_options, options)
55
+ L.U.Icon.prototype.initialize.call(this, map, options)
56
+ },
57
+
58
+ _setIconStyles: function (img, name) {
59
+ L.U.Icon.prototype._setIconStyles.call(this, img, name)
60
+ const color = this._getColor(),
61
+ opacity = this._getOpacity()
62
+ this.elements.container.style.backgroundColor = color
63
+ this.elements.arrow.style.borderTopColor = color
64
+ this.elements.container.style.opacity = opacity
65
+ this.elements.arrow.style.opacity = opacity
66
+ },
67
+
68
+ onAdd: function () {
69
+ const src = this._getIconUrl('icon')
70
+ const bgcolor = this._getColor()
71
+ L.U.Icon.setIconContrast(this.elements.icon, this.elements.container, src, bgcolor)
72
+ },
73
+
74
+ createIcon: function () {
75
+ this.elements = {}
76
+ this.elements.main = L.DomUtil.create('div')
77
+ this.elements.container = L.DomUtil.create(
78
+ 'div',
79
+ 'icon_container',
80
+ this.elements.main
81
+ )
82
+ this.elements.arrow = L.DomUtil.create('div', 'icon_arrow', this.elements.main)
83
+ const src = this._getIconUrl('icon')
84
+ if (src) {
85
+ this.elements.icon = L.U.Icon.makeIconElement(src, this.elements.container)
86
+ }
87
+ this._setIconStyles(this.elements.main, 'icon')
88
+ return this.elements.main
89
+ },
90
+ })
91
+
92
+ L.U.Icon.Circle = L.U.Icon.extend({
93
+ initialize: function (map, options) {
94
+ const default_options = {
95
+ popupAnchor: new L.Point(0, -6),
96
+ tooltipAnchor: new L.Point(6, 0),
97
+ className: 'umap-circle-icon',
98
+ }
99
+ options = L.Util.extend({}, default_options, options)
100
+ L.U.Icon.prototype.initialize.call(this, map, options)
101
+ },
102
+
103
+ _setIconStyles: function (img, name) {
104
+ L.U.Icon.prototype._setIconStyles.call(this, img, name)
105
+ this.elements.main.style.backgroundColor = this._getColor()
106
+ this.elements.main.style.opacity = this._getOpacity()
107
+ },
108
+
109
+ createIcon: function () {
110
+ this.elements = {}
111
+ this.elements.main = L.DomUtil.create('div')
112
+ this.elements.main.innerHTML = ' '
113
+ this._setIconStyles(this.elements.main, 'icon')
114
+ return this.elements.main
115
+ },
116
+ })
117
+
118
+ L.U.Icon.Drop = L.U.Icon.Default.extend({
119
+ default_options: {
120
+ iconAnchor: new L.Point(16, 42),
121
+ popupAnchor: new L.Point(0, -42),
122
+ tooltipAnchor: new L.Point(16, -24),
123
+ className: 'umap-drop-icon',
124
+ },
125
+ })
126
+
127
+ L.U.Icon.Ball = L.U.Icon.Default.extend({
128
+ default_options: {
129
+ iconAnchor: new L.Point(8, 30),
130
+ popupAnchor: new L.Point(0, -28),
131
+ tooltipAnchor: new L.Point(8, -23),
132
+ className: 'umap-ball-icon',
133
+ },
134
+
135
+ createIcon: function () {
136
+ this.elements = {}
137
+ this.elements.main = L.DomUtil.create('div')
138
+ this.elements.container = L.DomUtil.create(
139
+ 'div',
140
+ 'icon_container',
141
+ this.elements.main
142
+ )
143
+ this.elements.arrow = L.DomUtil.create('div', 'icon_arrow', this.elements.main)
144
+ this._setIconStyles(this.elements.main, 'icon')
145
+ return this.elements.main
146
+ },
147
+
148
+ _setIconStyles: function (img, name) {
149
+ L.U.Icon.prototype._setIconStyles.call(this, img, name)
150
+ const color = this._getColor('color')
151
+ let background
152
+ if (L.Browser.ielt9) {
153
+ background = color
154
+ } else if (L.Browser.webkit) {
155
+ background = `-webkit-gradient( radial, 6 38%, 0, 6 38%, 8, from(white), to(${color}) )`
156
+ } else {
157
+ background = `radial-gradient(circle at 6px 38% , white -4px, ${color} 8px) repeat scroll 0 0 transparent`
158
+ }
159
+ this.elements.container.style.background = background
160
+ this.elements.container.style.opacity = this._getOpacity()
161
+ },
162
+ })
163
+
164
+ L.U.Icon.Cluster = L.DivIcon.extend({
165
+ options: {
166
+ iconSize: [40, 40],
167
+ },
168
+
169
+ initialize: function (datalayer, cluster) {
170
+ this.datalayer = datalayer
171
+ this.cluster = cluster
172
+ },
173
+
174
+ createIcon: function () {
175
+ const container = L.DomUtil.create('div', 'leaflet-marker-icon marker-cluster'),
176
+ div = L.DomUtil.create('div', '', container),
177
+ span = L.DomUtil.create('span', '', div),
178
+ backgroundColor = this.datalayer.getColor()
179
+ span.textContent = this.cluster.getChildCount()
180
+ div.style.backgroundColor = backgroundColor
181
+ return container
182
+ },
183
+
184
+ computeTextColor: function (el) {
185
+ let color
186
+ const backgroundColor = this.datalayer.getColor()
187
+ if (this.datalayer.options.cluster && this.datalayer.options.cluster.textColor) {
188
+ color = this.datalayer.options.cluster.textColor
189
+ }
190
+ return color || L.DomUtil.TextColorFromBackgroundColor(el, backgroundColor)
191
+ },
192
+ })
193
+
194
+ L.U.Icon.isImg = function (src) {
195
+ return L.Util.isPath(src) || L.Util.isRemoteUrl(src) || L.Util.isDataImage(src)
196
+ }
197
+
198
+ L.U.Icon.makeIconElement = function (src, parent) {
199
+ let icon
200
+ if (L.U.Icon.isImg(src)) {
201
+ icon = L.DomUtil.create('img')
202
+ icon.src = src
203
+ } else {
204
+ icon = L.DomUtil.create('span')
205
+ icon.textContent = src
206
+ }
207
+ parent.appendChild(icon)
208
+ return icon
209
+ }
210
+
211
+ L.U.Icon.setIconContrast = function (icon, parent, src, bgcolor) {
212
+ /*
213
+ * icon: the element we'll adapt the style, it can be an image or text
214
+ * parent: the element we'll consider to decide whether to adapt the style,
215
+ * by looking at its background color
216
+ * src: the raw "icon" value, can be an URL, a path, text, emoticon, etc.
217
+ * bgcolor: the background color, used for caching and in case we cannot guess the
218
+ * parent background color
219
+ */
220
+ if (!icon) return
221
+
222
+ if (L.DomUtil.contrastedColor(parent, bgcolor)) {
223
+ // Decide whether to switch svg to white or not, but do it
224
+ // only for internal SVG, as invert could do weird things
225
+ if (L.Util.isPath(src) && src.endsWith('.svg')) {
226
+ // Must be called after icon container is added to the DOM
227
+ // An image
228
+ icon.style.filter = 'invert(1)'
229
+ } else if (!icon.src) {
230
+ // Text icon
231
+ icon.style.color = 'white'
232
+ }
233
+ }
234
+ }
@@ -0,0 +1,166 @@
1
+ L.U.Importer = L.Class.extend({
2
+ TYPES: ['geojson', 'csv', 'gpx', 'kml', 'osm', 'georss', 'umap'],
3
+ initialize: function (map) {
4
+ this.map = map
5
+ this.presets = map.options.importPresets
6
+ },
7
+
8
+ build: function () {
9
+ this.container = L.DomUtil.create('div', 'umap-upload')
10
+ this.title = L.DomUtil.add('h3', '', this.container, L._('Import data'))
11
+ this.presetBox = L.DomUtil.create('div', 'formbox', this.container)
12
+ this.presetSelect = L.DomUtil.create('select', '', this.presetBox)
13
+ this.fileBox = L.DomUtil.create('div', 'formbox', this.container)
14
+ this.fileInput = L.DomUtil.element(
15
+ 'input',
16
+ { type: 'file', multiple: 'multiple', autofocus: true },
17
+ this.fileBox
18
+ )
19
+ this.urlInput = L.DomUtil.element(
20
+ 'input',
21
+ { type: 'text', placeholder: L._('Provide an URL here') },
22
+ this.container
23
+ )
24
+ this.rawInput = L.DomUtil.element(
25
+ 'textarea',
26
+ { placeholder: L._('Paste your data here') },
27
+ this.container
28
+ )
29
+ this.typeLabel = L.DomUtil.add(
30
+ 'label',
31
+ '',
32
+ this.container,
33
+ L._('Choose the format of the data to import')
34
+ )
35
+ this.layerLabel = L.DomUtil.add(
36
+ 'label',
37
+ '',
38
+ this.container,
39
+ L._('Choose the layer to import in')
40
+ )
41
+ this.clearLabel = L.DomUtil.add(
42
+ 'label',
43
+ '',
44
+ this.container,
45
+ L._('Replace layer content')
46
+ )
47
+ this.submitInput = L.DomUtil.element(
48
+ 'input',
49
+ { type: 'button', value: L._('Import'), className: 'button' },
50
+ this.container
51
+ )
52
+ this.map.help.button(this.typeLabel, 'importFormats')
53
+ this.typeInput = L.DomUtil.element('select', { name: 'format' }, this.typeLabel)
54
+ this.layerInput = L.DomUtil.element(
55
+ 'select',
56
+ { name: 'datalayer' },
57
+ this.layerLabel
58
+ )
59
+ this.clearFlag = L.DomUtil.element(
60
+ 'input',
61
+ { type: 'checkbox', name: 'clear' },
62
+ this.clearLabel
63
+ )
64
+ let option
65
+ this.map.eachDataLayerReverse((datalayer) => {
66
+ if (datalayer.isLoaded() && !datalayer.isRemoteLayer()) {
67
+ const id = L.stamp(datalayer)
68
+ option = L.DomUtil.add('option', '', this.layerInput, datalayer.options.name)
69
+ option.value = id
70
+ }
71
+ })
72
+ L.DomUtil.element(
73
+ 'option',
74
+ { value: '', textContent: L._('Import in a new layer') },
75
+ this.layerInput
76
+ )
77
+ L.DomUtil.element(
78
+ 'option',
79
+ { value: '', textContent: L._('Choose the data format') },
80
+ this.typeInput
81
+ )
82
+ for (let i = 0; i < this.TYPES.length; i++) {
83
+ option = L.DomUtil.create('option', '', this.typeInput)
84
+ option.value = option.textContent = this.TYPES[i]
85
+ }
86
+ if (this.presets.length) {
87
+ const noPreset = L.DomUtil.create('option', '', this.presetSelect)
88
+ noPreset.value = noPreset.textContent = L._('Choose a preset')
89
+ for (let j = 0; j < this.presets.length; j++) {
90
+ option = L.DomUtil.create('option', '', presetSelect)
91
+ option.value = this.presets[j].url
92
+ option.textContent = this.presets[j].label
93
+ }
94
+ } else {
95
+ this.presetBox.style.display = 'none'
96
+ }
97
+ L.DomEvent.on(this.submitInput, 'click', this.submit, this)
98
+ L.DomEvent.on(
99
+ this.fileInput,
100
+ 'change',
101
+ (e) => {
102
+ let type = '',
103
+ newType
104
+ for (let i = 0; i < e.target.files.length; i++) {
105
+ newType = L.Util.detectFileType(e.target.files[i])
106
+ if (!type && newType) type = newType
107
+ if (type && newType !== type) {
108
+ type = ''
109
+ break
110
+ }
111
+ }
112
+ this.typeInput.value = type
113
+ },
114
+ this
115
+ )
116
+ },
117
+
118
+ open: function () {
119
+ if (!this.container) this.build()
120
+ this.map.ui.openPanel({ data: { html: this.container }, className: 'dark' })
121
+ },
122
+
123
+ openFiles: function () {
124
+ this.open()
125
+ this.fileInput.showPicker()
126
+ },
127
+
128
+ submit: function () {
129
+ let type = this.typeInput.value
130
+ const layerId = this.layerInput[this.layerInput.selectedIndex].value
131
+ let layer
132
+ if (type === 'umap') {
133
+ this.map.once('postsync', this.map._setDefaultCenter)
134
+ }
135
+ if (layerId) layer = this.map.datalayers[layerId]
136
+ if (layer && this.clearFlag.checked) layer.empty()
137
+ if (this.fileInput.files.length) {
138
+ for (let i = 0, file; (file = this.fileInput.files[i]); i++) {
139
+ this.map.processFileToImport(file, layer, type)
140
+ }
141
+ } else {
142
+ if (!type)
143
+ return this.map.ui.alert({
144
+ content: L._('Please choose a format'),
145
+ level: 'error',
146
+ })
147
+ if (this.rawInput.value && type === 'umap') {
148
+ try {
149
+ this.map.importRaw(this.rawInput.value, type)
150
+ } catch (e) {
151
+ this.ui.alert({ content: L._('Invalid umap data'), level: 'error' })
152
+ console.error(e)
153
+ }
154
+ } else {
155
+ if (!layer) layer = this.map.createDataLayer()
156
+ if (this.rawInput.value) layer.importRaw(this.rawInput.value, type)
157
+ else if (this.urlInput.value) layer.importFromUrl(this.urlInput.value, type)
158
+ else if (this.presetSelect.selectedIndex > 0)
159
+ layer.importFromUrl(
160
+ this.presetSelect[this.presetSelect.selectedIndex].value,
161
+ type
162
+ )
163
+ }
164
+ }
165
+ },
166
+ })