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.
- umap/__init__.py +1 -1
- umap/static/.gitignore +0 -0
- umap/static/umap/base.css +994 -0
- umap/static/umap/bitbucket.png +0 -0
- umap/static/umap/content.css +395 -0
- umap/static/umap/favicons/apple-touch-icon.png +0 -0
- umap/static/umap/favicons/favicon.ico +0 -0
- umap/static/umap/favicons/icon-192.png +0 -0
- umap/static/umap/favicons/icon-512.png +0 -0
- umap/static/umap/favicons/icon.svg +5 -0
- umap/static/umap/font/FiraSans-Light.woff +0 -0
- umap/static/umap/font/FiraSans-Light.woff2 +0 -0
- umap/static/umap/font/FiraSans-LightItalic.woff +0 -0
- umap/static/umap/font/FiraSans-LightItalic.woff2 +0 -0
- umap/static/umap/font/FiraSans-SemiBold.woff +0 -0
- umap/static/umap/font/FiraSans-SemiBold.woff2 +0 -0
- umap/static/umap/font.css +33 -0
- umap/static/umap/github.png +0 -0
- umap/static/umap/img/16-white.svg +190 -0
- umap/static/umap/img/16.svg +182 -0
- umap/static/umap/img/24-white.svg +62 -0
- umap/static/umap/img/24.svg +90 -0
- umap/static/umap/img/edit.svg +7 -0
- umap/static/umap/img/icon-bg.png +0 -0
- umap/static/umap/img/logo.svg +4 -0
- umap/static/umap/img/logo_filigree.png +0 -0
- umap/static/umap/img/logo_small.svg +14 -0
- umap/static/umap/img/marker.png +0 -0
- umap/static/umap/img/opensource.svg +7 -0
- umap/static/umap/img/osm.svg +7 -0
- umap/static/umap/img/search.gif +0 -0
- umap/static/umap/img/source/16-white.svg +980 -0
- umap/static/umap/img/source/16.svg +201 -0
- umap/static/umap/img/source/24-white.svg +83 -0
- umap/static/umap/img/source/24.svg +110 -0
- umap/static/umap/js/components/fragment.js +13 -0
- umap/static/umap/js/modules/global.js +8 -0
- umap/static/umap/js/modules/urls.js +29 -0
- umap/static/umap/js/umap.autocomplete.js +336 -0
- umap/static/umap/js/umap.browser.js +148 -0
- umap/static/umap/js/umap.controls.js +1542 -0
- umap/static/umap/js/umap.core.js +851 -0
- umap/static/umap/js/umap.datalayer.permissions.js +72 -0
- umap/static/umap/js/umap.features.js +1216 -0
- umap/static/umap/js/umap.forms.js +1267 -0
- umap/static/umap/js/umap.icon.js +234 -0
- umap/static/umap/js/umap.importer.js +166 -0
- umap/static/umap/js/umap.js +2010 -0
- umap/static/umap/js/umap.layer.js +1636 -0
- umap/static/umap/js/umap.permissions.js +212 -0
- umap/static/umap/js/umap.popup.js +340 -0
- umap/static/umap/js/umap.share.js +254 -0
- umap/static/umap/js/umap.slideshow.js +165 -0
- umap/static/umap/js/umap.tableeditor.js +120 -0
- umap/static/umap/js/umap.ui.js +240 -0
- umap/static/umap/js/umap.xhr.js +304 -0
- umap/static/umap/locale/am_ET.js +447 -0
- umap/static/umap/locale/am_ET.json +445 -0
- umap/static/umap/locale/ar.js +447 -0
- umap/static/umap/locale/ar.json +445 -0
- umap/static/umap/locale/ast.js +447 -0
- umap/static/umap/locale/ast.json +445 -0
- umap/static/umap/locale/bg.js +447 -0
- umap/static/umap/locale/bg.json +445 -0
- umap/static/umap/locale/br.js +447 -0
- umap/static/umap/locale/br.json +445 -0
- umap/static/umap/locale/ca.js +447 -0
- umap/static/umap/locale/ca.json +445 -0
- umap/static/umap/locale/cs_CZ.js +447 -0
- umap/static/umap/locale/cs_CZ.json +445 -0
- umap/static/umap/locale/da.js +447 -0
- umap/static/umap/locale/da.json +445 -0
- umap/static/umap/locale/de.js +447 -0
- umap/static/umap/locale/de.json +445 -0
- umap/static/umap/locale/el.js +447 -0
- umap/static/umap/locale/el.json +445 -0
- umap/static/umap/locale/en.js +447 -0
- umap/static/umap/locale/en.json +445 -0
- umap/static/umap/locale/en_US.json +445 -0
- umap/static/umap/locale/es.js +447 -0
- umap/static/umap/locale/es.json +445 -0
- umap/static/umap/locale/et.js +447 -0
- umap/static/umap/locale/et.json +445 -0
- umap/static/umap/locale/eu.js +413 -0
- umap/static/umap/locale/eu.json +411 -0
- umap/static/umap/locale/fa_IR.js +447 -0
- umap/static/umap/locale/fa_IR.json +445 -0
- umap/static/umap/locale/fi.js +447 -0
- umap/static/umap/locale/fi.json +445 -0
- umap/static/umap/locale/fr.js +447 -0
- umap/static/umap/locale/fr.json +445 -0
- umap/static/umap/locale/gl.js +447 -0
- umap/static/umap/locale/gl.json +445 -0
- umap/static/umap/locale/he.js +447 -0
- umap/static/umap/locale/he.json +445 -0
- umap/static/umap/locale/hr.js +447 -0
- umap/static/umap/locale/hr.json +445 -0
- umap/static/umap/locale/hu.js +447 -0
- umap/static/umap/locale/hu.json +445 -0
- umap/static/umap/locale/id.js +447 -0
- umap/static/umap/locale/id.json +445 -0
- umap/static/umap/locale/is.js +447 -0
- umap/static/umap/locale/is.json +445 -0
- umap/static/umap/locale/it.js +447 -0
- umap/static/umap/locale/it.json +445 -0
- umap/static/umap/locale/ja.js +447 -0
- umap/static/umap/locale/ja.json +445 -0
- umap/static/umap/locale/ko.js +447 -0
- umap/static/umap/locale/ko.json +445 -0
- umap/static/umap/locale/lt.js +447 -0
- umap/static/umap/locale/lt.json +445 -0
- umap/static/umap/locale/ms.js +447 -0
- umap/static/umap/locale/ms.json +445 -0
- umap/static/umap/locale/nl.js +447 -0
- umap/static/umap/locale/nl.json +445 -0
- umap/static/umap/locale/no.js +447 -0
- umap/static/umap/locale/no.json +445 -0
- umap/static/umap/locale/pl.js +447 -0
- umap/static/umap/locale/pl.json +445 -0
- umap/static/umap/locale/pl_PL.json +445 -0
- umap/static/umap/locale/pt.js +447 -0
- umap/static/umap/locale/pt.json +445 -0
- umap/static/umap/locale/pt_BR.js +447 -0
- umap/static/umap/locale/pt_BR.json +445 -0
- umap/static/umap/locale/pt_PT.js +447 -0
- umap/static/umap/locale/pt_PT.json +445 -0
- umap/static/umap/locale/ro.js +447 -0
- umap/static/umap/locale/ro.json +445 -0
- umap/static/umap/locale/ru.js +447 -0
- umap/static/umap/locale/ru.json +445 -0
- umap/static/umap/locale/si.js +439 -0
- umap/static/umap/locale/si.json +437 -0
- umap/static/umap/locale/sk_SK.js +447 -0
- umap/static/umap/locale/sk_SK.json +445 -0
- umap/static/umap/locale/sl.js +447 -0
- umap/static/umap/locale/sl.json +445 -0
- umap/static/umap/locale/sr.js +447 -0
- umap/static/umap/locale/sr.json +445 -0
- umap/static/umap/locale/sv.js +447 -0
- umap/static/umap/locale/sv.json +445 -0
- umap/static/umap/locale/th_TH.js +447 -0
- umap/static/umap/locale/th_TH.json +445 -0
- umap/static/umap/locale/tr.js +447 -0
- umap/static/umap/locale/tr.json +445 -0
- umap/static/umap/locale/uk_UA.js +447 -0
- umap/static/umap/locale/uk_UA.json +445 -0
- umap/static/umap/locale/vi.js +447 -0
- umap/static/umap/locale/vi.json +445 -0
- umap/static/umap/locale/vi_VN.json +445 -0
- umap/static/umap/locale/zh.js +447 -0
- umap/static/umap/locale/zh.json +445 -0
- umap/static/umap/locale/zh_CN.json +445 -0
- umap/static/umap/locale/zh_TW.Big5.json +445 -0
- umap/static/umap/locale/zh_TW.js +447 -0
- umap/static/umap/locale/zh_TW.json +445 -0
- umap/static/umap/map.css +1843 -0
- umap/static/umap/nav.css +81 -0
- umap/static/umap/openstreetmap.png +0 -0
- umap/static/umap/test/.eslintrc +22 -0
- umap/static/umap/test/Choropleth.js +243 -0
- umap/static/umap/test/Controls.js +100 -0
- umap/static/umap/test/DataLayer.js +495 -0
- umap/static/umap/test/Feature.js +382 -0
- umap/static/umap/test/Map.Export.js +106 -0
- umap/static/umap/test/Map.Init.js +46 -0
- umap/static/umap/test/Map.js +342 -0
- umap/static/umap/test/Marker.js +122 -0
- umap/static/umap/test/Permissions.js +74 -0
- umap/static/umap/test/Polygon.js +367 -0
- umap/static/umap/test/Polyline.js +402 -0
- umap/static/umap/test/TableEditor.js +100 -0
- umap/static/umap/test/URLs.js +54 -0
- umap/static/umap/test/Util.js +549 -0
- umap/static/umap/test/_pre.js +460 -0
- umap/static/umap/test/index.html +135 -0
- umap/static/umap/theme.css +1 -0
- umap/static/umap/twitter.png +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/METADATA +1 -1
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/RECORD +182 -6
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/WHEEL +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/entry_points.txt +0 -0
- {umap_project-1.14.0a1.dist-info → umap_project-1.14.0a2.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
L.U.Share = L.Class.extend({
|
|
2
|
+
EXPORT_TYPES: {
|
|
3
|
+
geojson: {
|
|
4
|
+
formatter: function (map) {
|
|
5
|
+
return JSON.stringify(map.toGeoJSON(), null, 2)
|
|
6
|
+
},
|
|
7
|
+
ext: '.geojson',
|
|
8
|
+
filetype: 'application/json',
|
|
9
|
+
},
|
|
10
|
+
gpx: {
|
|
11
|
+
formatter: function (map) {
|
|
12
|
+
return togpx(map.toGeoJSON())
|
|
13
|
+
},
|
|
14
|
+
ext: '.gpx',
|
|
15
|
+
filetype: 'application/gpx+xml',
|
|
16
|
+
},
|
|
17
|
+
kml: {
|
|
18
|
+
formatter: function (map) {
|
|
19
|
+
return tokml(map.toGeoJSON())
|
|
20
|
+
},
|
|
21
|
+
ext: '.kml',
|
|
22
|
+
filetype: 'application/vnd.google-earth.kml+xml',
|
|
23
|
+
},
|
|
24
|
+
csv: {
|
|
25
|
+
formatter: function (map) {
|
|
26
|
+
const table = []
|
|
27
|
+
map.eachFeature((feature) => {
|
|
28
|
+
const row = feature.toGeoJSON()['properties'],
|
|
29
|
+
center = feature.getCenter()
|
|
30
|
+
delete row['_umap_options']
|
|
31
|
+
row['Latitude'] = center.lat
|
|
32
|
+
row['Longitude'] = center.lng
|
|
33
|
+
table.push(row)
|
|
34
|
+
})
|
|
35
|
+
return csv2geojson.dsv.csvFormat(table)
|
|
36
|
+
},
|
|
37
|
+
ext: '.csv',
|
|
38
|
+
filetype: 'text/csv',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
initialize: function (map) {
|
|
43
|
+
this.map = map
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
build: function () {
|
|
47
|
+
this.container = L.DomUtil.create('div', 'umap-share')
|
|
48
|
+
this.title = L.DomUtil.create('h3', '', this.container)
|
|
49
|
+
this.title.textContent = L._('Share and download')
|
|
50
|
+
|
|
51
|
+
L.DomUtil.createCopiableInput(
|
|
52
|
+
this.container,
|
|
53
|
+
L._('Link to view the map'),
|
|
54
|
+
window.location.protocol + L.Util.getBaseUrl()
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
if (this.map.options.shortUrl) {
|
|
58
|
+
L.DomUtil.createCopiableInput(
|
|
59
|
+
this.container,
|
|
60
|
+
L._('Short link'),
|
|
61
|
+
this.map.options.shortUrl
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
L.DomUtil.create('hr', '', this.container)
|
|
66
|
+
|
|
67
|
+
L.DomUtil.add('h4', '', this.container, L._('Download'))
|
|
68
|
+
L.DomUtil.add('small', 'label', this.container, L._("Only visible layers' data"))
|
|
69
|
+
for (const key in this.EXPORT_TYPES) {
|
|
70
|
+
if (this.EXPORT_TYPES.hasOwnProperty(key)) {
|
|
71
|
+
L.DomUtil.createButton(
|
|
72
|
+
'download-file',
|
|
73
|
+
this.container,
|
|
74
|
+
this.EXPORT_TYPES[key].name || key,
|
|
75
|
+
() => this.download(key),
|
|
76
|
+
this
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
L.DomUtil.create('div', 'vspace', this.container)
|
|
81
|
+
L.DomUtil.add(
|
|
82
|
+
'small',
|
|
83
|
+
'label',
|
|
84
|
+
this.container,
|
|
85
|
+
L._('All data and settings of the map')
|
|
86
|
+
)
|
|
87
|
+
const downloadUrl = L.Util.template(this.map.options.urls.map_download, {
|
|
88
|
+
map_id: this.map.options.umap_id,
|
|
89
|
+
})
|
|
90
|
+
const link = L.DomUtil.createLink(
|
|
91
|
+
'download-backup',
|
|
92
|
+
this.container,
|
|
93
|
+
L._('full backup'),
|
|
94
|
+
downloadUrl
|
|
95
|
+
)
|
|
96
|
+
let name = this.map.options.name || 'data'
|
|
97
|
+
name = name.replace(/[^a-z0-9]/gi, '_').toLowerCase()
|
|
98
|
+
link.setAttribute('download', `${name}.umap`)
|
|
99
|
+
L.DomUtil.create('hr', '', this.container)
|
|
100
|
+
|
|
101
|
+
const embedTitle = L.DomUtil.add('h4', '', this.container, L._('Embed the map'))
|
|
102
|
+
const iframe = L.DomUtil.create('textarea', 'umap-share-iframe', this.container)
|
|
103
|
+
const urlTitle = L.DomUtil.add('h4', '', this.container, L._('Direct link'))
|
|
104
|
+
const exportUrl = L.DomUtil.createCopiableInput(
|
|
105
|
+
this.container,
|
|
106
|
+
L._('Share this link to open a customized map view'),
|
|
107
|
+
''
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
exportUrl.type = 'text'
|
|
111
|
+
const UIFields = [
|
|
112
|
+
['dimensions.width', { handler: 'Input', label: L._('width') }],
|
|
113
|
+
['dimensions.height', { handler: 'Input', label: L._('height') }],
|
|
114
|
+
[
|
|
115
|
+
'options.includeFullScreenLink',
|
|
116
|
+
{ handler: 'Switch', label: L._('Include full screen link?') },
|
|
117
|
+
],
|
|
118
|
+
[
|
|
119
|
+
'options.currentView',
|
|
120
|
+
{ handler: 'Switch', label: L._('Current view instead of default map view?') },
|
|
121
|
+
],
|
|
122
|
+
[
|
|
123
|
+
'options.keepCurrentDatalayers',
|
|
124
|
+
{ handler: 'Switch', label: L._('Keep current visible layers') },
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
'options.viewCurrentFeature',
|
|
128
|
+
{ handler: 'Switch', label: L._('Open current feature on load') },
|
|
129
|
+
],
|
|
130
|
+
'queryString.moreControl',
|
|
131
|
+
'queryString.scrollWheelZoom',
|
|
132
|
+
'queryString.miniMap',
|
|
133
|
+
'queryString.scaleControl',
|
|
134
|
+
'queryString.onLoadPanel',
|
|
135
|
+
'queryString.captionBar',
|
|
136
|
+
'queryString.captionMenus',
|
|
137
|
+
]
|
|
138
|
+
for (let i = 0; i < this.map.HIDDABLE_CONTROLS.length; i++) {
|
|
139
|
+
UIFields.push(`queryString.${this.map.HIDDABLE_CONTROLS[i]}Control`)
|
|
140
|
+
}
|
|
141
|
+
const iframeExporter = new L.U.IframeExporter(this.map)
|
|
142
|
+
const buildIframeCode = () => {
|
|
143
|
+
iframe.innerHTML = iframeExporter.build()
|
|
144
|
+
exportUrl.value = window.location.protocol + iframeExporter.buildUrl()
|
|
145
|
+
}
|
|
146
|
+
buildIframeCode()
|
|
147
|
+
const builder = new L.U.FormBuilder(iframeExporter, UIFields, {
|
|
148
|
+
callback: buildIframeCode,
|
|
149
|
+
})
|
|
150
|
+
const iframeOptions = L.DomUtil.createFieldset(
|
|
151
|
+
this.container,
|
|
152
|
+
L._('Embed and link options')
|
|
153
|
+
)
|
|
154
|
+
iframeOptions.appendChild(builder.build())
|
|
155
|
+
},
|
|
156
|
+
|
|
157
|
+
open: function () {
|
|
158
|
+
if (!this.container) this.build()
|
|
159
|
+
this.map.ui.openPanel({ data: { html: this.container } })
|
|
160
|
+
},
|
|
161
|
+
|
|
162
|
+
format: function (mode) {
|
|
163
|
+
const type = this.EXPORT_TYPES[mode]
|
|
164
|
+
const content = type.formatter(this.map)
|
|
165
|
+
let name = this.map.options.name || 'data'
|
|
166
|
+
name = name.replace(/[^a-z0-9]/gi, '_').toLowerCase()
|
|
167
|
+
const filename = name + type.ext
|
|
168
|
+
return { content, filetype: type.filetype, filename }
|
|
169
|
+
},
|
|
170
|
+
|
|
171
|
+
download: function (mode) {
|
|
172
|
+
const { content, filetype, filename } = this.format(mode)
|
|
173
|
+
const blob = new Blob([content], { type: filetype })
|
|
174
|
+
window.URL = window.URL || window.webkitURL
|
|
175
|
+
const el = document.createElement('a')
|
|
176
|
+
el.download = filename
|
|
177
|
+
el.href = window.URL.createObjectURL(blob)
|
|
178
|
+
el.style.display = 'none'
|
|
179
|
+
document.body.appendChild(el)
|
|
180
|
+
el.click()
|
|
181
|
+
document.body.removeChild(el)
|
|
182
|
+
},
|
|
183
|
+
})
|
|
184
|
+
|
|
185
|
+
L.U.IframeExporter = L.Evented.extend({
|
|
186
|
+
options: {
|
|
187
|
+
includeFullScreenLink: true,
|
|
188
|
+
currentView: false,
|
|
189
|
+
keepCurrentDatalayers: false,
|
|
190
|
+
viewCurrentFeature: false,
|
|
191
|
+
},
|
|
192
|
+
|
|
193
|
+
queryString: {
|
|
194
|
+
scaleControl: false,
|
|
195
|
+
miniMap: false,
|
|
196
|
+
scrollWheelZoom: false,
|
|
197
|
+
zoomControl: true,
|
|
198
|
+
editMode: 'disabled',
|
|
199
|
+
moreControl: true,
|
|
200
|
+
searchControl: null,
|
|
201
|
+
tilelayersControl: null,
|
|
202
|
+
embedControl: null,
|
|
203
|
+
datalayersControl: true,
|
|
204
|
+
onLoadPanel: 'none',
|
|
205
|
+
captionBar: false,
|
|
206
|
+
captionMenus: true,
|
|
207
|
+
},
|
|
208
|
+
|
|
209
|
+
dimensions: {
|
|
210
|
+
width: '100%',
|
|
211
|
+
height: '300px',
|
|
212
|
+
},
|
|
213
|
+
|
|
214
|
+
initialize: function (map) {
|
|
215
|
+
this.map = map
|
|
216
|
+
this.baseUrl = L.Util.getBaseUrl()
|
|
217
|
+
// Use map default, not generic default
|
|
218
|
+
this.queryString.onLoadPanel = this.map.options.onLoadPanel
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
getMap: function () {
|
|
222
|
+
return this.map
|
|
223
|
+
},
|
|
224
|
+
|
|
225
|
+
buildUrl: function (options) {
|
|
226
|
+
const datalayers = []
|
|
227
|
+
if (this.options.viewCurrentFeature && this.map.currentFeature) {
|
|
228
|
+
this.queryString.feature = this.map.currentFeature.getSlug()
|
|
229
|
+
}
|
|
230
|
+
if (this.options.keepCurrentDatalayers) {
|
|
231
|
+
this.map.eachDataLayer((datalayer) => {
|
|
232
|
+
if (datalayer.isVisible() && datalayer.umap_id) {
|
|
233
|
+
datalayers.push(datalayer.umap_id)
|
|
234
|
+
}
|
|
235
|
+
})
|
|
236
|
+
this.queryString.datalayers = datalayers.join(',')
|
|
237
|
+
} else {
|
|
238
|
+
delete this.queryString.datalayers
|
|
239
|
+
}
|
|
240
|
+
const currentView = this.options.currentView ? window.location.hash : ''
|
|
241
|
+
const queryString = L.extend({}, this.queryString, options)
|
|
242
|
+
return `${this.baseUrl}?${L.Util.buildQueryString(queryString)}${currentView}`
|
|
243
|
+
},
|
|
244
|
+
|
|
245
|
+
build: function () {
|
|
246
|
+
const iframeUrl = this.buildUrl()
|
|
247
|
+
let code = `<iframe width="${this.dimensions.width}" height="${this.dimensions.height}" frameborder="0" allowfullscreen allow="geolocation" src="${iframeUrl}"></iframe>`
|
|
248
|
+
if (this.options.includeFullScreenLink) {
|
|
249
|
+
const fullUrl = this.buildUrl({ scrollWheelZoom: true })
|
|
250
|
+
code += `<p><a href="${fullUrl}">${L._('See full screen')}</a></p>`
|
|
251
|
+
}
|
|
252
|
+
return code
|
|
253
|
+
},
|
|
254
|
+
})
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
L.U.Slideshow = L.Class.extend({
|
|
2
|
+
statics: {
|
|
3
|
+
CLASSNAME: 'umap-slideshow-active',
|
|
4
|
+
},
|
|
5
|
+
|
|
6
|
+
options: {
|
|
7
|
+
delay: 5000,
|
|
8
|
+
autoplay: false,
|
|
9
|
+
},
|
|
10
|
+
|
|
11
|
+
initialize: function (map, options) {
|
|
12
|
+
this.setOptions(options)
|
|
13
|
+
this.map = map
|
|
14
|
+
this._id = null
|
|
15
|
+
|
|
16
|
+
// current feature
|
|
17
|
+
let current = null
|
|
18
|
+
|
|
19
|
+
const self = this
|
|
20
|
+
try {
|
|
21
|
+
Object.defineProperty(this, 'current', {
|
|
22
|
+
get: function () {
|
|
23
|
+
if (!current) {
|
|
24
|
+
const datalayer = this.defaultDatalayer()
|
|
25
|
+
if (datalayer) current = datalayer.getFeatureByIndex(0)
|
|
26
|
+
}
|
|
27
|
+
return current
|
|
28
|
+
},
|
|
29
|
+
set: function (feature) {
|
|
30
|
+
current = feature
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
} catch (e) {
|
|
34
|
+
// Certainly IE8, which has a limited version of defineProperty
|
|
35
|
+
}
|
|
36
|
+
try {
|
|
37
|
+
Object.defineProperty(this, 'next', {
|
|
38
|
+
get: function () {
|
|
39
|
+
if (!current) {
|
|
40
|
+
return self.current
|
|
41
|
+
}
|
|
42
|
+
return current.getNext()
|
|
43
|
+
},
|
|
44
|
+
})
|
|
45
|
+
} catch (e) {
|
|
46
|
+
// Certainly IE8, which has a limited version of defineProperty
|
|
47
|
+
}
|
|
48
|
+
if (this.options.autoplay) {
|
|
49
|
+
this.map.onceDataLoaded(function () {
|
|
50
|
+
this.play()
|
|
51
|
+
}, this)
|
|
52
|
+
}
|
|
53
|
+
this.map.on(
|
|
54
|
+
'edit:enabled',
|
|
55
|
+
function () {
|
|
56
|
+
this.stop()
|
|
57
|
+
},
|
|
58
|
+
this
|
|
59
|
+
)
|
|
60
|
+
},
|
|
61
|
+
|
|
62
|
+
setOptions: function (options) {
|
|
63
|
+
L.setOptions(this, options)
|
|
64
|
+
this.timeSpinner()
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
defaultDatalayer: function () {
|
|
68
|
+
return this.map.findDataLayer((d) => d.allowBrowse() && d.hasData())
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
timeSpinner: function () {
|
|
72
|
+
const time = parseInt(this.options.delay, 10)
|
|
73
|
+
if (!time) return
|
|
74
|
+
const css = `rotation ${time / 1000}s infinite linear`,
|
|
75
|
+
spinners = document.querySelectorAll('.umap-slideshow-toolbox .play .spinner')
|
|
76
|
+
for (let i = 0; i < spinners.length; i++) {
|
|
77
|
+
spinners[i].style.animation = css
|
|
78
|
+
spinners[i].style['-webkit-animation'] = css
|
|
79
|
+
spinners[i].style['-moz-animation'] = css
|
|
80
|
+
spinners[i].style['-o-animation'] = css
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
resetSpinners: function () {
|
|
85
|
+
// Make that animnation is coordinated with user actions
|
|
86
|
+
const spinners = document.querySelectorAll('.umap-slideshow-toolbox .play .spinner')
|
|
87
|
+
|
|
88
|
+
let el
|
|
89
|
+
let newOne
|
|
90
|
+
for (let i = 0; i < spinners.length; i++) {
|
|
91
|
+
el = spinners[i]
|
|
92
|
+
newOne = el.cloneNode(true)
|
|
93
|
+
el.parentNode.replaceChild(newOne, el)
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
play: function () {
|
|
98
|
+
if (this._id) return
|
|
99
|
+
if (this.map.editEnabled || !this.map.options.slideshow.active) return
|
|
100
|
+
L.DomUtil.addClass(document.body, L.U.Slideshow.CLASSNAME)
|
|
101
|
+
this._id = window.setInterval(L.bind(this.loop, this), this.options.delay)
|
|
102
|
+
this.resetSpinners()
|
|
103
|
+
this.loop()
|
|
104
|
+
},
|
|
105
|
+
|
|
106
|
+
loop: function () {
|
|
107
|
+
this.current = this.next
|
|
108
|
+
this.step()
|
|
109
|
+
},
|
|
110
|
+
|
|
111
|
+
pause: function () {
|
|
112
|
+
if (this._id) {
|
|
113
|
+
L.DomUtil.removeClass(document.body, L.U.Slideshow.CLASSNAME)
|
|
114
|
+
window.clearInterval(this._id)
|
|
115
|
+
this._id = null
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
|
|
119
|
+
stop: function () {
|
|
120
|
+
this.pause()
|
|
121
|
+
this.current = null
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
forward: function () {
|
|
125
|
+
this.pause()
|
|
126
|
+
this.current = this.next
|
|
127
|
+
this.step()
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
backward: function () {
|
|
131
|
+
this.pause()
|
|
132
|
+
if (this.current) this.current = this.current.getPrevious()
|
|
133
|
+
this.step()
|
|
134
|
+
},
|
|
135
|
+
|
|
136
|
+
step: function () {
|
|
137
|
+
if (!this.current) return this.stop()
|
|
138
|
+
this.current.zoomTo({ easing: this.options.easing })
|
|
139
|
+
this.current.view()
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
renderToolbox: function (container) {
|
|
143
|
+
const box = L.DomUtil.create('ul', 'umap-slideshow-toolbox'),
|
|
144
|
+
play = L.DomUtil.create('li', 'play', box),
|
|
145
|
+
stop = L.DomUtil.create('li', 'stop', box),
|
|
146
|
+
prev = L.DomUtil.create('li', 'prev', box),
|
|
147
|
+
next = L.DomUtil.create('li', 'next', box)
|
|
148
|
+
L.DomUtil.create('div', 'spinner', play)
|
|
149
|
+
play.title = L._('Start slideshow')
|
|
150
|
+
stop.title = L._('Stop slideshow')
|
|
151
|
+
next.title = L._('Zoom to the next')
|
|
152
|
+
prev.title = L._('Zoom to the previous')
|
|
153
|
+
const toggle = function () {
|
|
154
|
+
if (this._id) this.pause()
|
|
155
|
+
else this.play()
|
|
156
|
+
}
|
|
157
|
+
L.DomEvent.on(play, 'click', L.DomEvent.stop).on(play, 'click', toggle, this)
|
|
158
|
+
L.DomEvent.on(stop, 'click', L.DomEvent.stop).on(stop, 'click', this.stop, this)
|
|
159
|
+
L.DomEvent.on(prev, 'click', L.DomEvent.stop).on(prev, 'click', this.backward, this)
|
|
160
|
+
L.DomEvent.on(next, 'click', L.DomEvent.stop).on(next, 'click', this.forward, this)
|
|
161
|
+
container.appendChild(box)
|
|
162
|
+
this.timeSpinner()
|
|
163
|
+
return box
|
|
164
|
+
},
|
|
165
|
+
})
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
L.U.TableEditor = L.Class.extend({
|
|
2
|
+
initialize: function (datalayer) {
|
|
3
|
+
this.datalayer = datalayer
|
|
4
|
+
this.table = L.DomUtil.create('div', 'table')
|
|
5
|
+
this.header = L.DomUtil.create('div', 'thead', this.table)
|
|
6
|
+
this.body = L.DomUtil.create('div', 'tbody', this.table)
|
|
7
|
+
this.resetProperties()
|
|
8
|
+
},
|
|
9
|
+
|
|
10
|
+
renderHeaders: function () {
|
|
11
|
+
this.header.innerHTML = ''
|
|
12
|
+
for (let i = 0; i < this.properties.length; i++) {
|
|
13
|
+
this.renderHeader(this.properties[i])
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
renderHeader: function (property) {
|
|
18
|
+
const container = L.DomUtil.create('div', 'tcell', this.header),
|
|
19
|
+
title = L.DomUtil.add('span', '', container, property),
|
|
20
|
+
del = L.DomUtil.create('i', 'umap-delete', container),
|
|
21
|
+
rename = L.DomUtil.create('i', 'umap-edit', container)
|
|
22
|
+
del.title = L._('Delete this property on all the features')
|
|
23
|
+
rename.title = L._('Rename this property on all the features')
|
|
24
|
+
const doDelete = function () {
|
|
25
|
+
if (
|
|
26
|
+
confirm(
|
|
27
|
+
L._('Are you sure you want to delete this property on all the features?')
|
|
28
|
+
)
|
|
29
|
+
) {
|
|
30
|
+
this.datalayer.eachLayer((feature) => {
|
|
31
|
+
feature.deleteProperty(property)
|
|
32
|
+
})
|
|
33
|
+
this.datalayer.deindexProperty(property)
|
|
34
|
+
this.resetProperties()
|
|
35
|
+
this.edit()
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
const doRename = function () {
|
|
39
|
+
const newName = prompt(
|
|
40
|
+
L._('Please enter the new name of this property'),
|
|
41
|
+
property
|
|
42
|
+
)
|
|
43
|
+
if (!newName || !this.validateName(newName)) return
|
|
44
|
+
this.datalayer.eachLayer((feature) => {
|
|
45
|
+
feature.renameProperty(property, newName)
|
|
46
|
+
})
|
|
47
|
+
this.datalayer.deindexProperty(property)
|
|
48
|
+
this.datalayer.indexProperty(newName)
|
|
49
|
+
this.resetProperties()
|
|
50
|
+
this.edit()
|
|
51
|
+
}
|
|
52
|
+
L.DomEvent.on(del, 'click', doDelete, this)
|
|
53
|
+
L.DomEvent.on(rename, 'click', doRename, this)
|
|
54
|
+
},
|
|
55
|
+
|
|
56
|
+
renderRow: function (feature) {
|
|
57
|
+
const builder = new L.U.FormBuilder(feature, this.field_properties, {
|
|
58
|
+
id: `umap-feature-properties_${L.stamp(feature)}`,
|
|
59
|
+
className: 'trow',
|
|
60
|
+
callback: feature.resetTooltip,
|
|
61
|
+
})
|
|
62
|
+
this.body.appendChild(builder.build())
|
|
63
|
+
},
|
|
64
|
+
|
|
65
|
+
compileProperties: function () {
|
|
66
|
+
if (this.properties.length === 0) this.properties = ['name']
|
|
67
|
+
// description is a forced textarea, don't edit it in a text input, or you lose cariage returns
|
|
68
|
+
if (this.properties.indexOf('description') !== -1)
|
|
69
|
+
this.properties.splice(this.properties.indexOf('description'), 1)
|
|
70
|
+
this.properties.sort()
|
|
71
|
+
this.field_properties = []
|
|
72
|
+
for (let i = 0; i < this.properties.length; i++) {
|
|
73
|
+
this.field_properties.push([
|
|
74
|
+
`properties.${this.properties[i]}`,
|
|
75
|
+
{ wrapper: 'div', wrapperClass: 'tcell' },
|
|
76
|
+
])
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
|
|
80
|
+
resetProperties: function () {
|
|
81
|
+
this.properties = this.datalayer._propertiesIndex
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
validateName: function (name) {
|
|
85
|
+
if (name.indexOf('.') !== -1) {
|
|
86
|
+
this.datalayer.map.ui.alert({
|
|
87
|
+
content: L._('Invalide property name: {name}', { name: name }),
|
|
88
|
+
level: 'error',
|
|
89
|
+
})
|
|
90
|
+
return false
|
|
91
|
+
}
|
|
92
|
+
return true
|
|
93
|
+
},
|
|
94
|
+
|
|
95
|
+
edit: function () {
|
|
96
|
+
const id = 'tableeditor:edit'
|
|
97
|
+
this.datalayer.map.fire('dataloading', { id: id })
|
|
98
|
+
this.compileProperties()
|
|
99
|
+
this.renderHeaders()
|
|
100
|
+
this.body.innerHTML = ''
|
|
101
|
+
this.datalayer.eachLayer(this.renderRow, this)
|
|
102
|
+
const addButton = L.DomUtil.create('li', 'add-property')
|
|
103
|
+
L.DomUtil.create('i', 'umap-icon-16 umap-add', addButton)
|
|
104
|
+
const label = L.DomUtil.create('span', '', addButton)
|
|
105
|
+
label.textContent = label.title = L._('Add a new property')
|
|
106
|
+
const addProperty = function () {
|
|
107
|
+
const newName = prompt(L._('Please enter the name of the property'))
|
|
108
|
+
if (!newName || !this.validateName(newName)) return
|
|
109
|
+
this.datalayer.indexProperty(newName)
|
|
110
|
+
this.edit()
|
|
111
|
+
}
|
|
112
|
+
L.DomEvent.on(addButton, 'click', addProperty, this)
|
|
113
|
+
this.datalayer.map.ui.openPanel({
|
|
114
|
+
data: { html: this.table },
|
|
115
|
+
className: 'umap-table-editor fullwidth dark',
|
|
116
|
+
actions: [addButton],
|
|
117
|
+
})
|
|
118
|
+
this.datalayer.map.fire('dataload', { id: id })
|
|
119
|
+
},
|
|
120
|
+
})
|