umap-project 3.2.0__py3-none-any.whl → 3.3.1__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +42 -38
- umap/locale/en/LC_MESSAGES/django.mo +0 -0
- umap/locale/en/LC_MESSAGES/django.po +15 -15
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +39 -35
- umap/locale/nl/LC_MESSAGES/django.mo +0 -0
- umap/locale/nl/LC_MESSAGES/django.po +31 -27
- umap/settings/base.py +2 -0
- umap/static/umap/css/contextmenu.css +58 -2
- umap/static/umap/css/form.css +175 -45
- umap/static/umap/css/icon.css +20 -0
- umap/static/umap/img/16-white.svg +21 -40
- umap/static/umap/img/16.svg +1 -1
- umap/static/umap/img/24-white.svg +9 -9
- umap/static/umap/img/24.svg +23 -10
- umap/static/umap/img/source/16-white.svg +23 -41
- umap/static/umap/img/source/16.svg +1 -1
- umap/static/umap/img/source/24-white.svg +11 -11
- umap/static/umap/img/source/24.svg +25 -12
- umap/static/umap/js/modules/caption.js +8 -0
- umap/static/umap/js/modules/data/features.js +318 -174
- umap/static/umap/js/modules/data/layer.js +27 -20
- umap/static/umap/js/modules/form/builder.js +11 -7
- umap/static/umap/js/modules/form/fields.js +10 -7
- umap/static/umap/js/modules/formatter.js +42 -20
- umap/static/umap/js/modules/importer.js +6 -1
- umap/static/umap/js/modules/importers/opendata.js +125 -37
- umap/static/umap/js/modules/importers/openrouteservice.js +140 -0
- umap/static/umap/js/modules/managers.js +12 -4
- umap/static/umap/js/modules/printer.js +107 -0
- umap/static/umap/js/modules/rendering/controls.js +78 -2
- umap/static/umap/js/modules/rendering/icon.js +113 -82
- umap/static/umap/js/modules/rendering/layers/cluster.js +220 -64
- umap/static/umap/js/modules/rendering/map.js +5 -1
- umap/static/umap/js/modules/rendering/template.js +71 -1
- umap/static/umap/js/modules/rendering/ui.js +101 -34
- umap/static/umap/js/modules/schema.js +24 -0
- umap/static/umap/js/modules/share.js +19 -12
- umap/static/umap/js/modules/ui/bar.js +6 -1
- umap/static/umap/js/modules/ui/base.js +24 -9
- umap/static/umap/js/modules/ui/contextmenu.js +17 -7
- umap/static/umap/js/modules/ui/dialog.js +7 -4
- umap/static/umap/js/modules/umap.js +68 -62
- umap/static/umap/js/umap.controls.js +22 -57
- umap/static/umap/locale/am_ET.js +39 -4
- umap/static/umap/locale/am_ET.json +39 -4
- umap/static/umap/locale/ar.js +39 -4
- umap/static/umap/locale/ar.json +39 -4
- umap/static/umap/locale/ast.js +39 -4
- umap/static/umap/locale/ast.json +39 -4
- umap/static/umap/locale/bg.js +39 -4
- umap/static/umap/locale/bg.json +39 -4
- umap/static/umap/locale/br.js +39 -4
- umap/static/umap/locale/br.json +39 -4
- umap/static/umap/locale/ca.js +39 -4
- umap/static/umap/locale/ca.json +39 -4
- umap/static/umap/locale/cs_CZ.js +39 -4
- umap/static/umap/locale/cs_CZ.json +39 -4
- umap/static/umap/locale/da.js +47 -12
- umap/static/umap/locale/da.json +47 -12
- umap/static/umap/locale/de.js +39 -4
- umap/static/umap/locale/de.json +39 -4
- umap/static/umap/locale/el.js +81 -46
- umap/static/umap/locale/el.json +81 -46
- umap/static/umap/locale/en.js +38 -4
- umap/static/umap/locale/en.json +38 -4
- umap/static/umap/locale/en_US.json +39 -4
- umap/static/umap/locale/es.js +47 -12
- umap/static/umap/locale/es.json +47 -12
- umap/static/umap/locale/et.js +39 -4
- umap/static/umap/locale/et.json +39 -4
- umap/static/umap/locale/eu.js +80 -45
- umap/static/umap/locale/eu.json +80 -45
- umap/static/umap/locale/fa_IR.js +39 -4
- umap/static/umap/locale/fa_IR.json +39 -4
- umap/static/umap/locale/fi.js +39 -4
- umap/static/umap/locale/fi.json +39 -4
- umap/static/umap/locale/fr.js +39 -4
- umap/static/umap/locale/fr.json +39 -4
- umap/static/umap/locale/gl.js +39 -4
- umap/static/umap/locale/gl.json +39 -4
- umap/static/umap/locale/he.js +39 -4
- umap/static/umap/locale/he.json +39 -4
- umap/static/umap/locale/hr.js +39 -4
- umap/static/umap/locale/hr.json +39 -4
- umap/static/umap/locale/hu.js +55 -20
- umap/static/umap/locale/hu.json +55 -20
- umap/static/umap/locale/id.js +39 -4
- umap/static/umap/locale/id.json +39 -4
- umap/static/umap/locale/is.js +39 -4
- umap/static/umap/locale/is.json +39 -4
- umap/static/umap/locale/it.js +39 -4
- umap/static/umap/locale/it.json +39 -4
- umap/static/umap/locale/ja.js +39 -4
- umap/static/umap/locale/ja.json +39 -4
- umap/static/umap/locale/ko.js +39 -4
- umap/static/umap/locale/ko.json +39 -4
- umap/static/umap/locale/lt.js +39 -4
- umap/static/umap/locale/lt.json +39 -4
- umap/static/umap/locale/ms.js +52 -17
- umap/static/umap/locale/ms.json +52 -17
- umap/static/umap/locale/nl.js +58 -23
- umap/static/umap/locale/nl.json +58 -23
- umap/static/umap/locale/no.js +39 -4
- umap/static/umap/locale/no.json +39 -4
- umap/static/umap/locale/pl.js +39 -4
- umap/static/umap/locale/pl.json +39 -4
- umap/static/umap/locale/pl_PL.json +39 -4
- umap/static/umap/locale/pt.js +39 -4
- umap/static/umap/locale/pt.json +39 -4
- umap/static/umap/locale/pt_BR.js +39 -4
- umap/static/umap/locale/pt_BR.json +39 -4
- umap/static/umap/locale/pt_PT.js +39 -4
- umap/static/umap/locale/pt_PT.json +39 -4
- umap/static/umap/locale/ro.js +39 -4
- umap/static/umap/locale/ro.json +39 -4
- umap/static/umap/locale/ru.js +39 -4
- umap/static/umap/locale/ru.json +39 -4
- umap/static/umap/locale/sk_SK.js +39 -4
- umap/static/umap/locale/sk_SK.json +39 -4
- umap/static/umap/locale/sl.js +39 -4
- umap/static/umap/locale/sl.json +39 -4
- umap/static/umap/locale/sr.js +39 -4
- umap/static/umap/locale/sr.json +39 -4
- umap/static/umap/locale/sv.js +39 -4
- umap/static/umap/locale/sv.json +39 -4
- umap/static/umap/locale/th_TH.js +39 -4
- umap/static/umap/locale/th_TH.json +39 -4
- umap/static/umap/locale/tr.js +39 -4
- umap/static/umap/locale/tr.json +39 -4
- umap/static/umap/locale/uk_UA.js +39 -4
- umap/static/umap/locale/uk_UA.json +39 -4
- umap/static/umap/locale/vi.js +39 -4
- umap/static/umap/locale/vi.json +39 -4
- umap/static/umap/locale/vi_VN.json +39 -4
- umap/static/umap/locale/zh.js +39 -4
- umap/static/umap/locale/zh.json +39 -4
- umap/static/umap/locale/zh_CN.json +39 -4
- umap/static/umap/locale/zh_TW.Big5.json +39 -4
- umap/static/umap/locale/zh_TW.js +98 -63
- umap/static/umap/locale/zh_TW.json +98 -63
- umap/static/umap/map.css +90 -41
- umap/static/umap/vars.css +1 -0
- umap/static/umap/vendors/editable/Leaflet.Editable.js +3 -1
- umap/static/umap/vendors/openrouteservice/ors-js-client.js +521 -0
- umap/static/umap/vendors/openrouteservice/ors-js-client.js.map +1 -0
- umap/static/umap/vendors/simple-elevation-chart/elevation.js +63 -0
- umap/static/umap/vendors/simple-elevation-chart/elevation.svg +8 -0
- umap/static/umap/vendors/snapdom/snapdom.min.mjs +3 -0
- umap/storage/staticfiles.py +12 -0
- umap/templates/umap/css.html +0 -4
- umap/templates/umap/js.html +1 -3
- umap/tests/integration/test_basics.py +2 -0
- umap/tests/integration/test_conditional_rules.py +17 -17
- umap/tests/integration/test_datalayer.py +1 -1
- umap/tests/integration/test_draw_polygon.py +3 -5
- umap/tests/integration/test_draw_polyline.py +4 -6
- umap/tests/integration/test_draw_route.py +178 -0
- umap/tests/integration/test_edit_map.py +1 -1
- umap/tests/integration/test_edit_marker.py +7 -7
- umap/tests/integration/test_edit_polygon.py +2 -2
- umap/tests/integration/test_export_map.py +74 -10
- umap/tests/integration/test_map_preview.py +1 -1
- umap/tests/integration/test_share.py +1 -1
- umap/tests/integration/test_tableeditor.py +4 -4
- umap/tests/integration/test_websocket_sync.py +4 -4
- umap/utils.py +5 -1
- umap/views.py +2 -0
- {umap_project-3.2.0.dist-info → umap_project-3.3.1.dist-info}/METADATA +9 -9
- {umap_project-3.2.0.dist-info → umap_project-3.3.1.dist-info}/RECORD +175 -171
- umap/static/umap/vendors/markercluster/MarkerCluster.Default.css +0 -60
- umap/static/umap/vendors/markercluster/MarkerCluster.css +0 -14
- umap/static/umap/vendors/markercluster/leaflet.markercluster.js +0 -2
- umap/static/umap/vendors/markercluster/leaflet.markercluster.js.map +0 -1
- {umap_project-3.2.0.dist-info → umap_project-3.3.1.dist-info}/WHEEL +0 -0
- {umap_project-3.2.0.dist-info → umap_project-3.3.1.dist-info}/entry_points.txt +0 -0
- {umap_project-3.2.0.dist-info → umap_project-3.3.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -63,6 +63,14 @@ export class FeatureManager extends Map {
|
|
|
63
63
|
this.set(feature.id, feature)
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
+
all() {
|
|
67
|
+
return Array.from(this.values())
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
visible() {
|
|
71
|
+
return this.all().filter((feature) => !feature.isFiltered())
|
|
72
|
+
}
|
|
73
|
+
|
|
66
74
|
del(feature) {
|
|
67
75
|
this.delete(feature.id)
|
|
68
76
|
}
|
|
@@ -72,7 +80,7 @@ export class FeatureManager extends Map {
|
|
|
72
80
|
}
|
|
73
81
|
|
|
74
82
|
sort(by) {
|
|
75
|
-
const features =
|
|
83
|
+
const features = this.all()
|
|
76
84
|
Utils.sortFeatures(features, by, U.lang)
|
|
77
85
|
this.clear()
|
|
78
86
|
for (const feature of features) {
|
|
@@ -90,16 +98,16 @@ export class FeatureManager extends Map {
|
|
|
90
98
|
}
|
|
91
99
|
|
|
92
100
|
last() {
|
|
93
|
-
return
|
|
101
|
+
return this.all()[this.size - 1]
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
next(feature) {
|
|
97
105
|
const index = this.getIndex(feature)
|
|
98
|
-
return
|
|
106
|
+
return this.all()[index + 1]
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
prev(feature) {
|
|
102
110
|
const index = this.getIndex(feature)
|
|
103
|
-
return
|
|
111
|
+
return this.all()[index - 1]
|
|
104
112
|
}
|
|
105
113
|
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { translate } from './i18n.js'
|
|
2
|
+
import * as Utils from './utils.js'
|
|
3
|
+
|
|
4
|
+
export default class Printer {
|
|
5
|
+
constructor(umap) {
|
|
6
|
+
this.umap = umap
|
|
7
|
+
this.dialog = this.umap.dialog
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
build() {
|
|
11
|
+
const [container, { format, mode, scale }] = Utils.loadTemplateWithRefs(`
|
|
12
|
+
<div>
|
|
13
|
+
<h3>${translate('Print map')}</h3>
|
|
14
|
+
<div class="formbox">
|
|
15
|
+
<label>${translate('Choose a format')}
|
|
16
|
+
<select name="format" data-ref="format">
|
|
17
|
+
<option value="a4">A4</option>
|
|
18
|
+
<option value="usletter">US Letter</option>
|
|
19
|
+
</select>
|
|
20
|
+
</label>
|
|
21
|
+
<label>${translate('Scale map')}
|
|
22
|
+
<input type="range" min="50" max="150" name="scale" data-ref="scale" />
|
|
23
|
+
</label>
|
|
24
|
+
<div class="umap-multiplechoice by2" data-ref="mode">
|
|
25
|
+
<input type="radio" name="mode" id="mode.0" value="portrait"><label for="mode.0">${translate('portrait')}</label>
|
|
26
|
+
<input type="radio" name="mode" id="mode.1" value="landscape" checked=""><label for="mode.1">${translate('landscape')}</label>
|
|
27
|
+
</div>
|
|
28
|
+
</div>
|
|
29
|
+
</div>
|
|
30
|
+
`)
|
|
31
|
+
this.container = container
|
|
32
|
+
format.addEventListener('change', () => this.resizeMap())
|
|
33
|
+
mode.addEventListener('change', () => this.resizeMap())
|
|
34
|
+
scale.addEventListener('change', () => this.resizeMap())
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
resetSize() {
|
|
38
|
+
const map = this.umap._leafletMap
|
|
39
|
+
for (const name of Array.from(map._container.classList)) {
|
|
40
|
+
if (name.startsWith('print-')) {
|
|
41
|
+
map._container.classList.remove(name)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
map._container.removeAttribute('style')
|
|
45
|
+
map.invalidateSize()
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
resizeMap() {
|
|
49
|
+
const form = this.dialog.collectFormData()
|
|
50
|
+
this.resetSize()
|
|
51
|
+
const map = this.umap._leafletMap
|
|
52
|
+
if (form.format && form.mode) {
|
|
53
|
+
map._container.classList.add(`print-${form.format}`)
|
|
54
|
+
map._container.classList.add(`print-${form.mode}`)
|
|
55
|
+
map._container.style.width = `${form.scale}%`
|
|
56
|
+
map.invalidateSize()
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
open(action = 'print') {
|
|
61
|
+
if (!this.container) this.build()
|
|
62
|
+
this.action = action
|
|
63
|
+
const acceptLabel = action === 'print' ? translate('Print') : translate('Download')
|
|
64
|
+
this.dialog.on(
|
|
65
|
+
'close',
|
|
66
|
+
(event) => {
|
|
67
|
+
if (event.target.returnValue !== 'accept') {
|
|
68
|
+
this.resetSize()
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{ once: true }
|
|
72
|
+
)
|
|
73
|
+
this.dialog
|
|
74
|
+
.open({ template: this.container, cancel: false, accept: acceptLabel })
|
|
75
|
+
.then((form) => this.onSubmit(form))
|
|
76
|
+
this.resizeMap()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async onSubmit(form) {
|
|
80
|
+
this.umap.fire('dataloading', { id: 'screenshot' })
|
|
81
|
+
if (this.action === 'print') {
|
|
82
|
+
const win = window.open('', '_blank')
|
|
83
|
+
// Using document.body.appendChild here will end with black font
|
|
84
|
+
// on a black blackground, no idea why.
|
|
85
|
+
win.document.write(`<span>${translate('Preparing the print…')}</span>`)
|
|
86
|
+
// screenshot must be called after window.open, no idea why,
|
|
87
|
+
// otherwise window.open sometimes fails and returns null.
|
|
88
|
+
const screenshot = await this.umap.screenshot()
|
|
89
|
+
const img = await screenshot.toPng()
|
|
90
|
+
img.addEventListener('load', () => {
|
|
91
|
+
win.print()
|
|
92
|
+
win.close()
|
|
93
|
+
})
|
|
94
|
+
win.document.querySelector('span').remove()
|
|
95
|
+
win.document.body.appendChild(img)
|
|
96
|
+
win.focus()
|
|
97
|
+
} else {
|
|
98
|
+
const screenshot = await this.umap.screenshot()
|
|
99
|
+
await screenshot.download({
|
|
100
|
+
format: this.action,
|
|
101
|
+
filename: Utils.slugify(this.umap.properties.name),
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
this.resetSize()
|
|
105
|
+
this.umap.fire('dataload', { id: 'screenshot' })
|
|
106
|
+
}
|
|
107
|
+
}
|
|
@@ -138,11 +138,21 @@ const BaseButton = Control.extend({
|
|
|
138
138
|
button.addEventListener('dblclick', (event) => {
|
|
139
139
|
event.stopPropagation()
|
|
140
140
|
})
|
|
141
|
-
this.
|
|
141
|
+
if (this.options.icon) {
|
|
142
|
+
button.appendChild(
|
|
143
|
+
Utils.loadTemplate(`<i class="icon icon-24 ${this.options.icon}"></i>`)
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
this.afterAdd(container, map)
|
|
142
147
|
return container
|
|
143
148
|
},
|
|
144
149
|
|
|
145
|
-
|
|
150
|
+
onRemove(map) {
|
|
151
|
+
this.afterRemove(map)
|
|
152
|
+
},
|
|
153
|
+
|
|
154
|
+
afterAdd: (container, map) => {},
|
|
155
|
+
afterRemove: (map) => {},
|
|
146
156
|
})
|
|
147
157
|
|
|
148
158
|
export const DataLayersControl = BaseButton.extend({
|
|
@@ -150,6 +160,7 @@ export const DataLayersControl = BaseButton.extend({
|
|
|
150
160
|
position: 'topleft',
|
|
151
161
|
className: 'umap-control-browse',
|
|
152
162
|
title: translate('Open browser'),
|
|
163
|
+
icon: 'icon-layers',
|
|
153
164
|
},
|
|
154
165
|
|
|
155
166
|
afterAdd: function (container) {
|
|
@@ -166,6 +177,7 @@ export const CaptionControl = BaseButton.extend({
|
|
|
166
177
|
position: 'topleft',
|
|
167
178
|
className: 'umap-control-caption',
|
|
168
179
|
title: translate('About'),
|
|
180
|
+
icon: 'icon-caption',
|
|
169
181
|
},
|
|
170
182
|
|
|
171
183
|
onClick: function () {
|
|
@@ -178,6 +190,7 @@ export const EmbedControl = BaseButton.extend({
|
|
|
178
190
|
position: 'topleft',
|
|
179
191
|
title: translate('Share and download'),
|
|
180
192
|
className: 'leaflet-control-embed',
|
|
193
|
+
icon: 'icon-share',
|
|
181
194
|
},
|
|
182
195
|
|
|
183
196
|
onClick: function () {
|
|
@@ -185,6 +198,69 @@ export const EmbedControl = BaseButton.extend({
|
|
|
185
198
|
},
|
|
186
199
|
})
|
|
187
200
|
|
|
201
|
+
export const PrintControl = BaseButton.extend({
|
|
202
|
+
options: {
|
|
203
|
+
position: 'topleft',
|
|
204
|
+
title: translate('Print'),
|
|
205
|
+
icon: 'icon-print',
|
|
206
|
+
},
|
|
207
|
+
|
|
208
|
+
onClick: function () {
|
|
209
|
+
this._umap.openPrinter('print')
|
|
210
|
+
},
|
|
211
|
+
})
|
|
212
|
+
|
|
213
|
+
export const SearchControl = BaseButton.extend({
|
|
214
|
+
options: {
|
|
215
|
+
position: 'topleft',
|
|
216
|
+
title: translate('Search location'),
|
|
217
|
+
className: 'leaflet-control-search',
|
|
218
|
+
icon: 'icon-search',
|
|
219
|
+
},
|
|
220
|
+
|
|
221
|
+
afterAdd(container, map) {
|
|
222
|
+
this.layer = L.layerGroup().addTo(map)
|
|
223
|
+
this.photonOptions = {
|
|
224
|
+
limit: 10,
|
|
225
|
+
noResultLabel: translate('No results'),
|
|
226
|
+
}
|
|
227
|
+
if (map.options.photonUrl) this.photonOptions.url = map.options.photonUrl
|
|
228
|
+
},
|
|
229
|
+
|
|
230
|
+
afterRemove: function (map) {
|
|
231
|
+
this.layer.remove()
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
onClick: function () {
|
|
235
|
+
const template = `
|
|
236
|
+
<div>
|
|
237
|
+
<h3><i class="icon icon-16 icon-search"></i>${translate('Search location')}</h3>
|
|
238
|
+
<input class="photon-input" data-ref=input />
|
|
239
|
+
<div class="photon-autocomplete" data-ref=resultsContainer></div>
|
|
240
|
+
</div>
|
|
241
|
+
`
|
|
242
|
+
const [container, { input, resultsContainer }] =
|
|
243
|
+
Utils.loadTemplateWithRefs(template)
|
|
244
|
+
const id = Math.random()
|
|
245
|
+
this._umap.panel.open({ content: container }).then(() => {
|
|
246
|
+
this.search = new U.Search(
|
|
247
|
+
this._umap._leafletMap,
|
|
248
|
+
input,
|
|
249
|
+
this.layer,
|
|
250
|
+
this.photonOptions
|
|
251
|
+
)
|
|
252
|
+
this.search.on('ajax:send', () => {
|
|
253
|
+
this._umap.fire('dataloading', { id: id })
|
|
254
|
+
})
|
|
255
|
+
this.search.on('ajax:return', () => {
|
|
256
|
+
this._umap.fire('dataload', { id: id })
|
|
257
|
+
})
|
|
258
|
+
this.search.resultsContainer = resultsContainer
|
|
259
|
+
input.focus()
|
|
260
|
+
})
|
|
261
|
+
},
|
|
262
|
+
})
|
|
263
|
+
|
|
188
264
|
export const AttributionControl = Control.Attribution.extend({
|
|
189
265
|
options: {
|
|
190
266
|
prefix: '',
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
DomEvent,
|
|
4
4
|
DomUtil,
|
|
5
5
|
Icon,
|
|
6
|
+
Point,
|
|
6
7
|
} from '../../../vendors/leaflet/leaflet-src.esm.js'
|
|
7
8
|
import { SCHEMA } from '../schema.js'
|
|
8
9
|
import * as Utils from '../utils.js'
|
|
@@ -11,6 +12,8 @@ export function getClass(name) {
|
|
|
11
12
|
switch (name) {
|
|
12
13
|
case 'Circle':
|
|
13
14
|
return Circle
|
|
15
|
+
case 'LargeCircle':
|
|
16
|
+
return LargeCircle
|
|
14
17
|
case 'Ball':
|
|
15
18
|
return Ball
|
|
16
19
|
case 'Drop':
|
|
@@ -25,13 +28,13 @@ export function getClass(name) {
|
|
|
25
28
|
export const RECENT = []
|
|
26
29
|
|
|
27
30
|
const BaseIcon = DivIcon.extend({
|
|
31
|
+
default_options: {
|
|
32
|
+
iconSize: null, // Made in css
|
|
33
|
+
iconUrl: SCHEMA.iconUrl.default,
|
|
34
|
+
feature: null,
|
|
35
|
+
},
|
|
28
36
|
initialize: function (options) {
|
|
29
|
-
|
|
30
|
-
iconSize: null, // Made in css
|
|
31
|
-
iconUrl: SCHEMA.iconUrl.default,
|
|
32
|
-
feature: null,
|
|
33
|
-
}
|
|
34
|
-
options = L.Util.extend({}, default_options, options)
|
|
37
|
+
options = { ...this.default_options, ...options }
|
|
35
38
|
Icon.prototype.initialize.call(this, options)
|
|
36
39
|
this.feature = this.options.feature
|
|
37
40
|
if (this.feature?.isReadOnly()) {
|
|
@@ -66,6 +69,10 @@ const BaseIcon = DivIcon.extend({
|
|
|
66
69
|
return color
|
|
67
70
|
},
|
|
68
71
|
|
|
72
|
+
_getSize: function () {
|
|
73
|
+
return this.feature?.getOption('iconSize') || SCHEMA.iconSize.default
|
|
74
|
+
},
|
|
75
|
+
|
|
69
76
|
_getOpacity: function () {
|
|
70
77
|
if (this.feature) return this.feature.getOption('iconOpacity')
|
|
71
78
|
return SCHEMA.iconOpacity.default
|
|
@@ -77,18 +84,33 @@ const BaseIcon = DivIcon.extend({
|
|
|
77
84
|
if (this.feature.isActive()) this.options.className += ' umap-icon-active'
|
|
78
85
|
DivIcon.prototype._setIconStyles.call(this, img, name)
|
|
79
86
|
},
|
|
87
|
+
|
|
88
|
+
createIcon: function () {
|
|
89
|
+
const [root, elements] = Utils.loadTemplateWithRefs(this.getTemplate())
|
|
90
|
+
this.root = root
|
|
91
|
+
this.elements = elements
|
|
92
|
+
this.root.dataset.feature = this.feature?.id
|
|
93
|
+
if (this.elements.container) {
|
|
94
|
+
const src = this._getIconUrl('icon')
|
|
95
|
+
if (src) {
|
|
96
|
+
this.elements.icon = makeElement(src, this.elements.container)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
this._setIconStyles(this.root, 'icon')
|
|
100
|
+
return this.root
|
|
101
|
+
},
|
|
80
102
|
})
|
|
81
103
|
|
|
82
104
|
const DefaultIcon = BaseIcon.extend({
|
|
83
105
|
default_options: {
|
|
84
|
-
iconAnchor: new
|
|
85
|
-
popupAnchor: new
|
|
86
|
-
tooltipAnchor: new
|
|
106
|
+
iconAnchor: new Point(16, 40),
|
|
107
|
+
popupAnchor: new Point(0, -40),
|
|
108
|
+
tooltipAnchor: new Point(16, -24),
|
|
87
109
|
className: 'umap-div-icon',
|
|
88
110
|
},
|
|
89
111
|
|
|
90
112
|
initialize: function (options) {
|
|
91
|
-
options =
|
|
113
|
+
options = { ...this.default_options, ...options }
|
|
92
114
|
BaseIcon.prototype.initialize.call(this, options)
|
|
93
115
|
},
|
|
94
116
|
|
|
@@ -108,92 +130,113 @@ const DefaultIcon = BaseIcon.extend({
|
|
|
108
130
|
setContrast(this.elements.icon, this.elements.container, src, bgcolor)
|
|
109
131
|
},
|
|
110
132
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
)
|
|
119
|
-
this.elements.main.dataset.feature = this.feature?.id
|
|
120
|
-
this.elements.arrow = DomUtil.create('div', 'icon_arrow', this.elements.main)
|
|
121
|
-
const src = this._getIconUrl('icon')
|
|
122
|
-
if (src) {
|
|
123
|
-
this.elements.icon = makeElement(src, this.elements.container)
|
|
124
|
-
}
|
|
125
|
-
this._setIconStyles(this.elements.main, 'icon')
|
|
126
|
-
return this.elements.main
|
|
133
|
+
getTemplate: () => {
|
|
134
|
+
return `
|
|
135
|
+
<div>
|
|
136
|
+
<div class="icon-container" data-ref=container></div>
|
|
137
|
+
<div class="icon-arrow" data-ref=arrow></div>
|
|
138
|
+
</div>
|
|
139
|
+
`
|
|
127
140
|
},
|
|
128
141
|
})
|
|
129
142
|
|
|
130
143
|
const Circle = BaseIcon.extend({
|
|
131
144
|
initialize: function (options) {
|
|
132
145
|
const default_options = {
|
|
133
|
-
|
|
134
|
-
|
|
146
|
+
iconSize: new Point(12, 12),
|
|
147
|
+
popupAnchor: new Point(0, -6),
|
|
148
|
+
tooltipAnchor: new Point(6, 0),
|
|
135
149
|
className: 'umap-circle-icon',
|
|
136
150
|
}
|
|
137
|
-
options =
|
|
151
|
+
options = { ...default_options, ...(options || {}) }
|
|
138
152
|
BaseIcon.prototype.initialize.call(this, options)
|
|
139
153
|
},
|
|
140
154
|
|
|
141
155
|
_setIconStyles: function (img, name) {
|
|
142
156
|
BaseIcon.prototype._setIconStyles.call(this, img, name)
|
|
143
|
-
this.
|
|
144
|
-
this.
|
|
157
|
+
this.root.style.backgroundColor = this._getColor()
|
|
158
|
+
this.root.style.opacity = this._getOpacity()
|
|
145
159
|
},
|
|
146
160
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
161
|
+
getTemplate: () => {
|
|
162
|
+
return '<div> </div>'
|
|
163
|
+
},
|
|
164
|
+
})
|
|
165
|
+
|
|
166
|
+
const LargeCircle = BaseIcon.extend({
|
|
167
|
+
default_options: {
|
|
168
|
+
className: 'umap-large-circle-icon',
|
|
169
|
+
},
|
|
170
|
+
initialize: function (options) {
|
|
171
|
+
BaseIcon.prototype.initialize.call(this, options)
|
|
172
|
+
const size = this._getSize()
|
|
173
|
+
this.options.popupAnchor = new Point(0, (size / 2) * -1)
|
|
174
|
+
this.options.tooltipAnchor = new Point(size / 2, 0)
|
|
175
|
+
this.options.iconAnchor = new Point(size / 2, size / 2)
|
|
176
|
+
},
|
|
177
|
+
|
|
178
|
+
_setIconStyles: function (img, name) {
|
|
179
|
+
BaseIcon.prototype._setIconStyles.call(this, img, name)
|
|
180
|
+
this.root.style.opacity = this._getOpacity()
|
|
181
|
+
this.root.style.borderColor = this._getColor()
|
|
182
|
+
this.root.style.width = `${this._getSize()}px`
|
|
183
|
+
this.root.style.height = `${this._getSize()}px`
|
|
184
|
+
},
|
|
185
|
+
|
|
186
|
+
getTemplate: () => {
|
|
187
|
+
return '<div data-ref=container></div>'
|
|
154
188
|
},
|
|
155
189
|
})
|
|
156
190
|
|
|
157
191
|
const Raw = DefaultIcon.extend({
|
|
158
192
|
default_options: {
|
|
159
|
-
iconSize: new L.Point(48, 48),
|
|
160
|
-
popupAnchor: new L.Point(0, 0),
|
|
161
|
-
tooltipAnchor: new L.Point(0, 0),
|
|
162
193
|
className: 'umap-raw-icon',
|
|
163
194
|
},
|
|
195
|
+
initialize: function (options) {
|
|
196
|
+
DefaultIcon.prototype.initialize.call(this, options)
|
|
197
|
+
const size = this._getSize()
|
|
198
|
+
this.options.popupAnchor = new Point(0, (size / 2) * -1)
|
|
199
|
+
this.options.tooltipAnchor = new Point(size / 2, 0)
|
|
200
|
+
this.options.iconAnchor = new Point(size / 2, size / 2)
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
_setIconStyles: function (img, name) {
|
|
204
|
+
BaseIcon.prototype._setIconStyles.call(this, img, name)
|
|
205
|
+
this.root.style.width = `${this._getSize()}px`
|
|
206
|
+
this.root.style.height = `${this._getSize()}px`
|
|
207
|
+
},
|
|
164
208
|
|
|
165
209
|
_getColor: () => 'transparent',
|
|
210
|
+
|
|
211
|
+
getTemplate: () => {
|
|
212
|
+
return '<div data-ref=container></div>'
|
|
213
|
+
},
|
|
166
214
|
})
|
|
167
215
|
|
|
168
216
|
const Drop = DefaultIcon.extend({
|
|
169
217
|
default_options: {
|
|
170
|
-
iconAnchor: new
|
|
171
|
-
popupAnchor: new
|
|
172
|
-
tooltipAnchor: new
|
|
218
|
+
iconAnchor: new Point(16, 42),
|
|
219
|
+
popupAnchor: new Point(0, -42),
|
|
220
|
+
tooltipAnchor: new Point(16, -24),
|
|
173
221
|
className: 'umap-drop-icon',
|
|
174
222
|
},
|
|
175
223
|
})
|
|
176
224
|
|
|
177
225
|
const Ball = DefaultIcon.extend({
|
|
178
226
|
default_options: {
|
|
179
|
-
iconAnchor: new
|
|
180
|
-
popupAnchor: new
|
|
181
|
-
tooltipAnchor: new
|
|
227
|
+
iconAnchor: new Point(8, 30),
|
|
228
|
+
popupAnchor: new Point(0, -28),
|
|
229
|
+
tooltipAnchor: new Point(8, -23),
|
|
182
230
|
className: 'umap-ball-icon',
|
|
183
231
|
},
|
|
184
232
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
)
|
|
193
|
-
this.elements.main.dataset.feature = this.feature?.id
|
|
194
|
-
this.elements.arrow = DomUtil.create('div', 'icon_arrow', this.elements.main)
|
|
195
|
-
this._setIconStyles(this.elements.main, 'icon')
|
|
196
|
-
return this.elements.main
|
|
233
|
+
getTemplate: () => {
|
|
234
|
+
return `
|
|
235
|
+
<div>
|
|
236
|
+
<div class="icon-container" data-ref=ball></div>
|
|
237
|
+
<div class="icon-arrow" data-ref=arrow></div>
|
|
238
|
+
</div>
|
|
239
|
+
`
|
|
197
240
|
},
|
|
198
241
|
|
|
199
242
|
_setIconStyles: function (img, name) {
|
|
@@ -207,38 +250,26 @@ const Ball = DefaultIcon.extend({
|
|
|
207
250
|
} else {
|
|
208
251
|
background = `radial-gradient(circle at 6px 38% , white -4px, ${color} 8px) repeat scroll 0 0 transparent`
|
|
209
252
|
}
|
|
210
|
-
this.elements.
|
|
211
|
-
this.elements.
|
|
253
|
+
this.elements.ball.style.background = background
|
|
254
|
+
this.elements.ball.style.opacity = this._getOpacity()
|
|
212
255
|
},
|
|
213
256
|
})
|
|
214
257
|
|
|
215
258
|
export const Cluster = DivIcon.extend({
|
|
216
259
|
options: {
|
|
217
260
|
iconSize: [40, 40],
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
initialize: function (datalayer, cluster) {
|
|
221
|
-
this.datalayer = datalayer
|
|
222
|
-
this.cluster = cluster
|
|
261
|
+
className: 'umap-cluster-icon',
|
|
223
262
|
},
|
|
224
263
|
|
|
225
264
|
createIcon: function () {
|
|
226
|
-
const
|
|
227
|
-
const
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
computeTextColor: function (el) {
|
|
236
|
-
let color
|
|
237
|
-
const backgroundColor = this.datalayer.getColor()
|
|
238
|
-
if (this.datalayer.properties.cluster?.textColor) {
|
|
239
|
-
color = this.datalayer.properties.cluster.textColor
|
|
240
|
-
}
|
|
241
|
-
return color || DomUtil.TextColorFromBackgroundColor(el, backgroundColor)
|
|
265
|
+
const template = '<div><span data-ref=counter></span></div>'
|
|
266
|
+
const [root, { counter }] = Utils.loadTemplateWithRefs(template)
|
|
267
|
+
this.root = root
|
|
268
|
+
this.counter = counter
|
|
269
|
+
this.counter.textContent = this.options.getCounter()
|
|
270
|
+
this.root.style.backgroundColor = this.options.color
|
|
271
|
+
this._setIconStyles(this.root, 'icon')
|
|
272
|
+
return this.root
|
|
242
273
|
},
|
|
243
274
|
})
|
|
244
275
|
|