umap-project 2.5.0__py3-none-any.whl → 2.6.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of umap-project might be problematic. Click here for more details.
- umap/__init__.py +1 -1
- umap/admin.py +6 -1
- umap/context_processors.py +2 -1
- umap/decorators.py +13 -2
- umap/forms.py +26 -2
- umap/locale/br/LC_MESSAGES/django.mo +0 -0
- umap/locale/br/LC_MESSAGES/django.po +252 -146
- umap/locale/ca/LC_MESSAGES/django.mo +0 -0
- umap/locale/ca/LC_MESSAGES/django.po +274 -162
- umap/locale/cs_CZ/LC_MESSAGES/django.mo +0 -0
- umap/locale/cs_CZ/LC_MESSAGES/django.po +261 -150
- umap/locale/de/LC_MESSAGES/django.mo +0 -0
- umap/locale/de/LC_MESSAGES/django.po +299 -187
- umap/locale/el/LC_MESSAGES/django.mo +0 -0
- umap/locale/el/LC_MESSAGES/django.po +215 -159
- umap/locale/en/LC_MESSAGES/django.po +211 -155
- umap/locale/es/LC_MESSAGES/django.mo +0 -0
- umap/locale/es/LC_MESSAGES/django.po +255 -144
- umap/locale/eu/LC_MESSAGES/django.mo +0 -0
- umap/locale/eu/LC_MESSAGES/django.po +254 -198
- umap/locale/fa_IR/LC_MESSAGES/django.mo +0 -0
- umap/locale/fa_IR/LC_MESSAGES/django.po +347 -235
- umap/locale/fr/LC_MESSAGES/django.mo +0 -0
- umap/locale/fr/LC_MESSAGES/django.po +216 -160
- umap/locale/hu/LC_MESSAGES/django.mo +0 -0
- umap/locale/hu/LC_MESSAGES/django.po +215 -159
- umap/locale/it/LC_MESSAGES/django.mo +0 -0
- umap/locale/it/LC_MESSAGES/django.po +252 -146
- umap/locale/ms/LC_MESSAGES/django.mo +0 -0
- umap/locale/ms/LC_MESSAGES/django.po +252 -146
- umap/locale/pl/LC_MESSAGES/django.mo +0 -0
- umap/locale/pl/LC_MESSAGES/django.po +254 -148
- umap/locale/pt/LC_MESSAGES/django.mo +0 -0
- umap/locale/pt/LC_MESSAGES/django.po +215 -159
- umap/locale/sv/LC_MESSAGES/django.mo +0 -0
- umap/locale/sv/LC_MESSAGES/django.po +254 -143
- umap/locale/th_TH/LC_MESSAGES/django.mo +0 -0
- umap/locale/th_TH/LC_MESSAGES/django.po +125 -70
- umap/locale/zh_TW/LC_MESSAGES/django.mo +0 -0
- umap/locale/zh_TW/LC_MESSAGES/django.po +256 -145
- umap/migrations/0022_add_team.py +94 -0
- umap/models.py +45 -10
- umap/settings/__init__.py +2 -0
- umap/settings/base.py +9 -2
- umap/static/umap/base.css +32 -41
- umap/static/umap/content.css +19 -25
- umap/static/umap/css/icon.css +63 -37
- umap/static/umap/css/importers.css +1 -1
- umap/static/umap/css/slideshow.css +7 -5
- umap/static/umap/css/tableeditor.css +4 -3
- umap/static/umap/img/16-white.svg +1 -4
- umap/static/umap/img/16.svg +2 -6
- umap/static/umap/img/24-white.svg +4 -4
- umap/static/umap/img/24.svg +6 -6
- umap/static/umap/img/source/16-white.svg +2 -5
- umap/static/umap/img/source/16.svg +3 -7
- umap/static/umap/img/source/24-white.svg +7 -14
- umap/static/umap/img/source/24.svg +10 -17
- umap/static/umap/js/components/alerts/alert.css +20 -8
- umap/static/umap/js/modules/autocomplete.js +8 -12
- umap/static/umap/js/modules/browser.js +4 -3
- umap/static/umap/js/modules/caption.js +9 -11
- umap/static/umap/js/modules/data/features.js +993 -0
- umap/static/umap/js/modules/data/layer.js +1210 -0
- umap/static/umap/js/modules/formatter.js +12 -3
- umap/static/umap/js/modules/global.js +21 -5
- umap/static/umap/js/modules/importers/overpass.js +22 -8
- umap/static/umap/js/modules/permissions.js +280 -0
- umap/static/umap/js/{umap.icon.js → modules/rendering/icon.js} +77 -56
- umap/static/umap/js/modules/rendering/layers/base.js +105 -0
- umap/static/umap/js/modules/rendering/layers/classified.js +484 -0
- umap/static/umap/js/modules/rendering/layers/cluster.js +103 -0
- umap/static/umap/js/modules/rendering/layers/heat.js +182 -0
- umap/static/umap/js/modules/rendering/popup.js +99 -0
- umap/static/umap/js/modules/rendering/template.js +217 -0
- umap/static/umap/js/modules/rendering/ui.js +610 -0
- umap/static/umap/js/modules/rules.js +16 -3
- umap/static/umap/js/modules/schema.js +25 -1
- umap/static/umap/js/modules/share.js +66 -45
- umap/static/umap/js/modules/sync/updaters.js +9 -10
- umap/static/umap/js/modules/tableeditor.js +7 -7
- umap/static/umap/js/modules/ui/dialog.js +8 -4
- umap/static/umap/js/modules/utils.js +22 -13
- umap/static/umap/js/umap.controls.js +80 -146
- umap/static/umap/js/umap.core.js +9 -9
- umap/static/umap/js/umap.forms.js +41 -17
- umap/static/umap/js/umap.js +72 -65
- umap/static/umap/locale/am_ET.js +8 -2
- umap/static/umap/locale/am_ET.json +8 -2
- umap/static/umap/locale/ar.js +8 -2
- umap/static/umap/locale/ar.json +8 -2
- umap/static/umap/locale/ast.js +8 -2
- umap/static/umap/locale/ast.json +8 -2
- umap/static/umap/locale/bg.js +8 -2
- umap/static/umap/locale/bg.json +8 -2
- umap/static/umap/locale/br.js +42 -36
- umap/static/umap/locale/br.json +42 -36
- umap/static/umap/locale/ca.js +67 -61
- umap/static/umap/locale/ca.json +67 -61
- umap/static/umap/locale/cs_CZ.js +8 -2
- umap/static/umap/locale/cs_CZ.json +8 -2
- umap/static/umap/locale/da.js +8 -2
- umap/static/umap/locale/da.json +8 -2
- umap/static/umap/locale/de.js +143 -137
- umap/static/umap/locale/de.json +143 -137
- umap/static/umap/locale/el.js +54 -48
- umap/static/umap/locale/el.json +54 -48
- umap/static/umap/locale/en.js +10 -2
- umap/static/umap/locale/en.json +10 -2
- umap/static/umap/locale/en_US.json +8 -2
- umap/static/umap/locale/es.js +8 -2
- umap/static/umap/locale/es.json +8 -2
- umap/static/umap/locale/et.js +8 -2
- umap/static/umap/locale/et.json +8 -2
- umap/static/umap/locale/eu.js +346 -338
- umap/static/umap/locale/eu.json +346 -338
- umap/static/umap/locale/fa_IR.js +415 -407
- umap/static/umap/locale/fa_IR.json +415 -407
- umap/static/umap/locale/fi.js +8 -2
- umap/static/umap/locale/fi.json +8 -2
- umap/static/umap/locale/fr.js +11 -3
- umap/static/umap/locale/fr.json +11 -3
- umap/static/umap/locale/gl.js +8 -2
- umap/static/umap/locale/gl.json +8 -2
- umap/static/umap/locale/he.js +8 -2
- umap/static/umap/locale/he.json +8 -2
- umap/static/umap/locale/hr.js +8 -2
- umap/static/umap/locale/hr.json +8 -2
- umap/static/umap/locale/hu.js +31 -23
- umap/static/umap/locale/hu.json +31 -23
- umap/static/umap/locale/id.js +8 -2
- umap/static/umap/locale/id.json +8 -2
- umap/static/umap/locale/is.js +8 -2
- umap/static/umap/locale/is.json +8 -2
- umap/static/umap/locale/it.js +8 -2
- umap/static/umap/locale/it.json +8 -2
- umap/static/umap/locale/ja.js +8 -2
- umap/static/umap/locale/ja.json +8 -2
- umap/static/umap/locale/ko.js +8 -2
- umap/static/umap/locale/ko.json +8 -2
- umap/static/umap/locale/lt.js +8 -2
- umap/static/umap/locale/lt.json +8 -2
- umap/static/umap/locale/ms.js +8 -2
- umap/static/umap/locale/ms.json +8 -2
- umap/static/umap/locale/nl.js +8 -2
- umap/static/umap/locale/nl.json +8 -2
- umap/static/umap/locale/no.js +8 -2
- umap/static/umap/locale/no.json +8 -2
- umap/static/umap/locale/pl.js +54 -48
- umap/static/umap/locale/pl.json +54 -48
- umap/static/umap/locale/pl_PL.json +8 -2
- umap/static/umap/locale/pt.js +24 -18
- umap/static/umap/locale/pt.json +24 -18
- umap/static/umap/locale/pt_BR.js +8 -2
- umap/static/umap/locale/pt_BR.json +8 -2
- umap/static/umap/locale/pt_PT.js +214 -208
- umap/static/umap/locale/pt_PT.json +214 -208
- umap/static/umap/locale/ro.js +8 -2
- umap/static/umap/locale/ro.json +8 -2
- umap/static/umap/locale/ru.js +8 -2
- umap/static/umap/locale/ru.json +8 -2
- umap/static/umap/locale/sk_SK.js +8 -2
- umap/static/umap/locale/sk_SK.json +8 -2
- umap/static/umap/locale/sl.js +8 -2
- umap/static/umap/locale/sl.json +8 -2
- umap/static/umap/locale/sr.js +8 -2
- umap/static/umap/locale/sr.json +8 -2
- umap/static/umap/locale/sv.js +8 -2
- umap/static/umap/locale/sv.json +8 -2
- umap/static/umap/locale/th_TH.js +33 -27
- umap/static/umap/locale/th_TH.json +33 -27
- umap/static/umap/locale/tr.js +8 -2
- umap/static/umap/locale/tr.json +8 -2
- umap/static/umap/locale/uk_UA.js +8 -2
- umap/static/umap/locale/uk_UA.json +8 -2
- umap/static/umap/locale/vi.js +8 -2
- umap/static/umap/locale/vi.json +8 -2
- umap/static/umap/locale/vi_VN.json +8 -2
- umap/static/umap/locale/zh.js +8 -2
- umap/static/umap/locale/zh.json +8 -2
- umap/static/umap/locale/zh_CN.json +8 -2
- umap/static/umap/locale/zh_TW.Big5.json +8 -2
- umap/static/umap/locale/zh_TW.js +102 -96
- umap/static/umap/locale/zh_TW.json +102 -96
- umap/static/umap/map.css +111 -108
- umap/static/umap/nav.css +19 -10
- umap/static/umap/unittests/utils.js +230 -107
- umap/static/umap/vars.css +1 -0
- umap/static/umap/vendors/csv2geojson/csv2geojson.js +62 -40
- umap/static/umap/vendors/editable/Leaflet.Editable.js +2079 -1937
- umap/storage.py +4 -3
- umap/templates/404.html +5 -1
- umap/templates/500.html +3 -1
- umap/templates/auth/user_detail.html +8 -2
- umap/templates/auth/user_form.html +19 -10
- umap/templates/auth/user_stars.html +8 -2
- umap/templates/base.html +1 -0
- umap/templates/registration/login.html +18 -3
- umap/templates/umap/about.html +1 -0
- umap/templates/umap/about_summary.html +22 -7
- umap/templates/umap/components/alerts/alert.html +42 -21
- umap/templates/umap/content.html +2 -0
- umap/templates/umap/content_footer.html +7 -3
- umap/templates/umap/css.html +1 -0
- umap/templates/umap/dashboard_menu.html +15 -0
- umap/templates/umap/home.html +14 -4
- umap/templates/umap/js.html +4 -9
- umap/templates/umap/login_popup_end.html +10 -4
- umap/templates/umap/map_detail.html +8 -2
- umap/templates/umap/map_fragment.html +3 -1
- umap/templates/umap/map_init.html +2 -1
- umap/templates/umap/map_list.html +6 -3
- umap/templates/umap/map_table.html +36 -12
- umap/templates/umap/messages.html +0 -1
- umap/templates/umap/navigation.html +2 -1
- umap/templates/umap/password_change.html +5 -1
- umap/templates/umap/password_change_done.html +8 -2
- umap/templates/umap/search.html +8 -2
- umap/templates/umap/search_bar.html +1 -0
- umap/templates/umap/team_confirm_delete.html +19 -0
- umap/templates/umap/team_detail.html +27 -0
- umap/templates/umap/team_form.html +60 -0
- umap/templates/umap/user_dashboard.html +7 -9
- umap/templates/umap/user_teams.html +51 -0
- umap/tests/base.py +8 -1
- umap/tests/conftest.py +6 -0
- umap/tests/fixtures/test_circles_layer.geojson +219 -0
- umap/tests/fixtures/test_upload_georss.xml +20 -0
- umap/tests/integration/conftest.py +18 -4
- umap/tests/integration/helpers.py +12 -0
- umap/tests/integration/test_anonymous_owned_map.py +23 -0
- umap/tests/integration/test_basics.py +29 -0
- umap/tests/integration/test_browser.py +20 -0
- umap/tests/integration/test_caption.py +20 -0
- umap/tests/integration/test_circles_layer.py +69 -0
- umap/tests/integration/test_conditional_rules.py +102 -17
- umap/tests/integration/test_draw_polygon.py +138 -13
- umap/tests/integration/test_draw_polyline.py +8 -18
- umap/tests/integration/test_edit_datalayer.py +3 -3
- umap/tests/integration/test_import.py +124 -5
- umap/tests/integration/test_owned_map.py +21 -13
- umap/tests/integration/test_querystring.py +7 -0
- umap/tests/integration/test_team.py +47 -0
- umap/tests/integration/test_tilelayer.py +19 -2
- umap/tests/integration/test_view_marker.py +28 -1
- umap/tests/integration/test_websocket_sync.py +5 -5
- umap/tests/test_datalayer.py +32 -7
- umap/tests/test_datalayer_views.py +1 -1
- umap/tests/test_map.py +30 -4
- umap/tests/test_map_views.py +2 -2
- umap/tests/test_statics.py +40 -0
- umap/tests/test_team_views.py +131 -0
- umap/tests/test_views.py +15 -1
- umap/urls.py +23 -13
- umap/views.py +116 -10
- {umap_project-2.5.0.dist-info → umap_project-2.6.0.dist-info}/METADATA +14 -14
- {umap_project-2.5.0.dist-info → umap_project-2.6.0.dist-info}/RECORD +260 -253
- umap/static/umap/js/umap.datalayer.permissions.js +0 -70
- umap/static/umap/js/umap.features.js +0 -1290
- umap/static/umap/js/umap.layer.js +0 -1837
- umap/static/umap/js/umap.permissions.js +0 -208
- umap/static/umap/js/umap.popup.js +0 -341
- umap/static/umap/test/TableEditor.js +0 -104
- umap/static/umap/vendors/leaflet/leaflet-src.js +0 -14512
- umap/static/umap/vendors/leaflet/leaflet-src.js.map +0 -1
- umap/static/umap/vendors/leaflet/leaflet.js +0 -6
- umap/static/umap/vendors/leaflet/leaflet.js.map +0 -1
- umap/static/umap/vendors/markercluster/WhereAreTheJavascriptFiles.txt +0 -5
- umap/static/umap/vendors/markercluster/leaflet.markercluster-src.js +0 -2718
- umap/static/umap/vendors/markercluster/leaflet.markercluster-src.js.map +0 -1
- umap/static/umap/vendors/toolbar/leaflet.toolbar-src.css +0 -117
- umap/static/umap/vendors/toolbar/leaflet.toolbar-src.js +0 -365
- umap/tests/integration/test_statics.py +0 -47
- {umap_project-2.5.0.dist-info → umap_project-2.6.0.dist-info}/WHEEL +0 -0
- {umap_project-2.5.0.dist-info → umap_project-2.6.0.dist-info}/entry_points.txt +0 -0
- {umap_project-2.5.0.dist-info → umap_project-2.6.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,16 +1,36 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import {
|
|
2
|
+
DomEvent,
|
|
3
|
+
DomUtil,
|
|
4
|
+
DivIcon,
|
|
5
|
+
Icon,
|
|
6
|
+
} from '../../../vendors/leaflet/leaflet-src.esm.js'
|
|
7
|
+
import * as Utils from '../utils.js'
|
|
8
|
+
import { SCHEMA } from '../schema.js'
|
|
9
|
+
|
|
10
|
+
export function getClass(name) {
|
|
11
|
+
switch (name) {
|
|
12
|
+
case 'Circle':
|
|
13
|
+
return Circle
|
|
14
|
+
case 'Ball':
|
|
15
|
+
return Ball
|
|
16
|
+
case 'Drop':
|
|
17
|
+
return Drop
|
|
18
|
+
default:
|
|
19
|
+
return DefaultIcon
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const RECENT = []
|
|
24
|
+
|
|
25
|
+
const BaseIcon = L.DivIcon.extend({
|
|
26
|
+
initialize: function (options) {
|
|
7
27
|
const default_options = {
|
|
8
28
|
iconSize: null, // Made in css
|
|
9
|
-
iconUrl:
|
|
29
|
+
iconUrl: SCHEMA.iconUrl.default,
|
|
10
30
|
feature: null,
|
|
11
31
|
}
|
|
12
32
|
options = L.Util.extend({}, default_options, options)
|
|
13
|
-
|
|
33
|
+
Icon.prototype.initialize.call(this, options)
|
|
14
34
|
this.feature = this.options.feature
|
|
15
35
|
if (this.feature?.isReadOnly()) {
|
|
16
36
|
this.options.className += ' readonly'
|
|
@@ -18,10 +38,10 @@ U.Icon = L.DivIcon.extend({
|
|
|
18
38
|
},
|
|
19
39
|
|
|
20
40
|
_setRecent: (url) => {
|
|
21
|
-
if (
|
|
22
|
-
if (url ===
|
|
23
|
-
if (
|
|
24
|
-
|
|
41
|
+
if (Utils.hasVar(url)) return
|
|
42
|
+
if (url === SCHEMA.iconUrl.default) return
|
|
43
|
+
if (RECENT.indexOf(url) === -1) {
|
|
44
|
+
RECENT.push(url)
|
|
25
45
|
}
|
|
26
46
|
},
|
|
27
47
|
|
|
@@ -33,29 +53,26 @@ U.Icon = L.DivIcon.extend({
|
|
|
33
53
|
} else {
|
|
34
54
|
url = this.options[`${name}Url`]
|
|
35
55
|
}
|
|
36
|
-
return
|
|
56
|
+
return formatUrl(url, this.feature)
|
|
37
57
|
},
|
|
38
58
|
|
|
39
59
|
_getColor: function () {
|
|
40
60
|
let color
|
|
41
61
|
if (this.feature) color = this.feature.getDynamicOption('color')
|
|
42
62
|
else if (this.options.color) color = this.options.color
|
|
43
|
-
else color =
|
|
63
|
+
else color = SCHEMA.color.default
|
|
44
64
|
return color
|
|
45
65
|
},
|
|
46
66
|
|
|
47
67
|
_getOpacity: function () {
|
|
48
68
|
if (this.feature) return this.feature.getOption('iconOpacity')
|
|
49
|
-
return
|
|
69
|
+
return SCHEMA.iconOpacity.default
|
|
50
70
|
},
|
|
51
71
|
|
|
52
|
-
formatUrl: (url, feature) =>
|
|
53
|
-
U.Utils.greedyTemplate(url || '', feature ? feature.extendedProperties() : {}),
|
|
54
|
-
|
|
55
72
|
onAdd: () => {},
|
|
56
73
|
})
|
|
57
74
|
|
|
58
|
-
|
|
75
|
+
const DefaultIcon = BaseIcon.extend({
|
|
59
76
|
default_options: {
|
|
60
77
|
iconAnchor: new L.Point(16, 40),
|
|
61
78
|
popupAnchor: new L.Point(0, -40),
|
|
@@ -63,13 +80,13 @@ U.Icon.Default = U.Icon.extend({
|
|
|
63
80
|
className: 'umap-div-icon',
|
|
64
81
|
},
|
|
65
82
|
|
|
66
|
-
initialize: function (
|
|
83
|
+
initialize: function (options) {
|
|
67
84
|
options = L.Util.extend({}, this.default_options, options)
|
|
68
|
-
|
|
85
|
+
BaseIcon.prototype.initialize.call(this, options)
|
|
69
86
|
},
|
|
70
87
|
|
|
71
88
|
_setIconStyles: function (img, name) {
|
|
72
|
-
|
|
89
|
+
BaseIcon.prototype._setIconStyles.call(this, img, name)
|
|
73
90
|
const color = this._getColor()
|
|
74
91
|
const opacity = this._getOpacity()
|
|
75
92
|
this.elements.container.style.backgroundColor = color
|
|
@@ -81,54 +98,56 @@ U.Icon.Default = U.Icon.extend({
|
|
|
81
98
|
onAdd: function () {
|
|
82
99
|
const src = this._getIconUrl('icon')
|
|
83
100
|
const bgcolor = this._getColor()
|
|
84
|
-
|
|
101
|
+
setContrast(this.elements.icon, this.elements.container, src, bgcolor)
|
|
85
102
|
},
|
|
86
103
|
|
|
87
104
|
createIcon: function () {
|
|
88
105
|
this.elements = {}
|
|
89
|
-
this.elements.main =
|
|
90
|
-
this.elements.container =
|
|
106
|
+
this.elements.main = DomUtil.create('div')
|
|
107
|
+
this.elements.container = DomUtil.create(
|
|
91
108
|
'div',
|
|
92
109
|
'icon_container',
|
|
93
110
|
this.elements.main
|
|
94
111
|
)
|
|
95
|
-
this.elements.
|
|
112
|
+
this.elements.main.dataset.feature = this.feature?.id
|
|
113
|
+
this.elements.arrow = DomUtil.create('div', 'icon_arrow', this.elements.main)
|
|
96
114
|
const src = this._getIconUrl('icon')
|
|
97
115
|
if (src) {
|
|
98
|
-
this.elements.icon =
|
|
116
|
+
this.elements.icon = makeElement(src, this.elements.container)
|
|
99
117
|
}
|
|
100
118
|
this._setIconStyles(this.elements.main, 'icon')
|
|
101
119
|
return this.elements.main
|
|
102
120
|
},
|
|
103
121
|
})
|
|
104
122
|
|
|
105
|
-
|
|
106
|
-
initialize: function (
|
|
123
|
+
const Circle = BaseIcon.extend({
|
|
124
|
+
initialize: function (options) {
|
|
107
125
|
const default_options = {
|
|
108
126
|
popupAnchor: new L.Point(0, -6),
|
|
109
127
|
tooltipAnchor: new L.Point(6, 0),
|
|
110
128
|
className: 'umap-circle-icon',
|
|
111
129
|
}
|
|
112
130
|
options = L.Util.extend({}, default_options, options)
|
|
113
|
-
|
|
131
|
+
BaseIcon.prototype.initialize.call(this, options)
|
|
114
132
|
},
|
|
115
133
|
|
|
116
134
|
_setIconStyles: function (img, name) {
|
|
117
|
-
|
|
135
|
+
BaseIcon.prototype._setIconStyles.call(this, img, name)
|
|
118
136
|
this.elements.main.style.backgroundColor = this._getColor()
|
|
119
137
|
this.elements.main.style.opacity = this._getOpacity()
|
|
120
138
|
},
|
|
121
139
|
|
|
122
140
|
createIcon: function () {
|
|
123
141
|
this.elements = {}
|
|
124
|
-
this.elements.main =
|
|
142
|
+
this.elements.main = DomUtil.create('div')
|
|
125
143
|
this.elements.main.innerHTML = ' '
|
|
126
144
|
this._setIconStyles(this.elements.main, 'icon')
|
|
145
|
+
this.elements.main.dataset.feature = this.feature?.id
|
|
127
146
|
return this.elements.main
|
|
128
147
|
},
|
|
129
148
|
})
|
|
130
149
|
|
|
131
|
-
|
|
150
|
+
const Drop = DefaultIcon.extend({
|
|
132
151
|
default_options: {
|
|
133
152
|
iconAnchor: new L.Point(16, 42),
|
|
134
153
|
popupAnchor: new L.Point(0, -42),
|
|
@@ -137,7 +156,7 @@ U.Icon.Drop = U.Icon.Default.extend({
|
|
|
137
156
|
},
|
|
138
157
|
})
|
|
139
158
|
|
|
140
|
-
|
|
159
|
+
const Ball = DefaultIcon.extend({
|
|
141
160
|
default_options: {
|
|
142
161
|
iconAnchor: new L.Point(8, 30),
|
|
143
162
|
popupAnchor: new L.Point(0, -28),
|
|
@@ -147,19 +166,20 @@ U.Icon.Ball = U.Icon.Default.extend({
|
|
|
147
166
|
|
|
148
167
|
createIcon: function () {
|
|
149
168
|
this.elements = {}
|
|
150
|
-
this.elements.main =
|
|
151
|
-
this.elements.container =
|
|
169
|
+
this.elements.main = DomUtil.create('div')
|
|
170
|
+
this.elements.container = DomUtil.create(
|
|
152
171
|
'div',
|
|
153
172
|
'icon_container',
|
|
154
173
|
this.elements.main
|
|
155
174
|
)
|
|
156
|
-
this.elements.
|
|
175
|
+
this.elements.main.dataset.feature = this.feature?.id
|
|
176
|
+
this.elements.arrow = DomUtil.create('div', 'icon_arrow', this.elements.main)
|
|
157
177
|
this._setIconStyles(this.elements.main, 'icon')
|
|
158
178
|
return this.elements.main
|
|
159
179
|
},
|
|
160
180
|
|
|
161
181
|
_setIconStyles: function (img, name) {
|
|
162
|
-
|
|
182
|
+
BaseIcon.prototype._setIconStyles.call(this, img, name)
|
|
163
183
|
const color = this._getColor('color')
|
|
164
184
|
let background
|
|
165
185
|
if (L.Browser.ielt9) {
|
|
@@ -174,7 +194,7 @@ U.Icon.Ball = U.Icon.Default.extend({
|
|
|
174
194
|
},
|
|
175
195
|
})
|
|
176
196
|
|
|
177
|
-
|
|
197
|
+
export const Cluster = DivIcon.extend({
|
|
178
198
|
options: {
|
|
179
199
|
iconSize: [40, 40],
|
|
180
200
|
},
|
|
@@ -185,9 +205,9 @@ U.Icon.Cluster = L.DivIcon.extend({
|
|
|
185
205
|
},
|
|
186
206
|
|
|
187
207
|
createIcon: function () {
|
|
188
|
-
const container =
|
|
189
|
-
const div =
|
|
190
|
-
const span =
|
|
208
|
+
const container = DomUtil.create('div', 'leaflet-marker-icon marker-cluster')
|
|
209
|
+
const div = DomUtil.create('div', '', container)
|
|
210
|
+
const span = DomUtil.create('span', '', div)
|
|
191
211
|
const backgroundColor = this.datalayer.getColor()
|
|
192
212
|
span.textContent = this.cluster.getChildCount()
|
|
193
213
|
div.style.backgroundColor = backgroundColor
|
|
@@ -200,27 +220,28 @@ U.Icon.Cluster = L.DivIcon.extend({
|
|
|
200
220
|
if (this.datalayer.options.cluster?.textColor) {
|
|
201
221
|
color = this.datalayer.options.cluster.textColor
|
|
202
222
|
}
|
|
203
|
-
return color ||
|
|
223
|
+
return color || DomUtil.TextColorFromBackgroundColor(el, backgroundColor)
|
|
204
224
|
},
|
|
205
225
|
})
|
|
206
226
|
|
|
207
|
-
|
|
208
|
-
|
|
227
|
+
export function isImg(src) {
|
|
228
|
+
return Utils.isPath(src) || Utils.isRemoteUrl(src) || Utils.isDataImage(src)
|
|
229
|
+
}
|
|
209
230
|
|
|
210
|
-
|
|
231
|
+
export function makeElement(src, parent) {
|
|
211
232
|
let icon
|
|
212
|
-
if (
|
|
213
|
-
icon =
|
|
233
|
+
if (isImg(src)) {
|
|
234
|
+
icon = DomUtil.create('img')
|
|
214
235
|
icon.src = src
|
|
215
236
|
} else {
|
|
216
|
-
icon =
|
|
237
|
+
icon = DomUtil.create('span')
|
|
217
238
|
icon.textContent = src
|
|
218
239
|
}
|
|
219
240
|
parent.appendChild(icon)
|
|
220
241
|
return icon
|
|
221
242
|
}
|
|
222
243
|
|
|
223
|
-
|
|
244
|
+
export function setContrast(icon, parent, src, bgcolor) {
|
|
224
245
|
/*
|
|
225
246
|
* icon: the element we'll adapt the style, it can be an image or text
|
|
226
247
|
* parent: the element we'll consider to decide whether to adapt the style,
|
|
@@ -231,14 +252,10 @@ U.Icon.setIconContrast = (icon, parent, src, bgcolor) => {
|
|
|
231
252
|
*/
|
|
232
253
|
if (!icon) return
|
|
233
254
|
|
|
234
|
-
if (
|
|
255
|
+
if (DomUtil.contrastedColor(parent, bgcolor)) {
|
|
235
256
|
// Decide whether to switch svg to white or not, but do it
|
|
236
257
|
// only for internal SVG, as invert could do weird things
|
|
237
|
-
if (
|
|
238
|
-
U.Utils.isPath(src) &&
|
|
239
|
-
src.endsWith('.svg') &&
|
|
240
|
-
src !== U.SCHEMA.iconUrl.default
|
|
241
|
-
) {
|
|
258
|
+
if (Utils.isPath(src) && src.endsWith('.svg') && src !== SCHEMA.iconUrl.default) {
|
|
242
259
|
// Must be called after icon container is added to the DOM
|
|
243
260
|
// An image
|
|
244
261
|
icon.style.filter = 'invert(1)'
|
|
@@ -248,3 +265,7 @@ U.Icon.setIconContrast = (icon, parent, src, bgcolor) => {
|
|
|
248
265
|
}
|
|
249
266
|
}
|
|
250
267
|
}
|
|
268
|
+
|
|
269
|
+
export function formatUrl(url, feature) {
|
|
270
|
+
return Utils.greedyTemplate(url || '', feature ? feature.extendedProperties() : {})
|
|
271
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { FeatureGroup, TileLayer } from '../../../../vendors/leaflet/leaflet-src.esm.js'
|
|
2
|
+
import { translate } from '../../i18n.js'
|
|
3
|
+
import * as Utils from '../../utils.js'
|
|
4
|
+
|
|
5
|
+
export const LayerMixin = {
|
|
6
|
+
browsable: true,
|
|
7
|
+
|
|
8
|
+
onInit: function (map) {
|
|
9
|
+
if (this.datalayer.autoLoaded()) map.on('zoomend', this.onZoomEnd, this)
|
|
10
|
+
},
|
|
11
|
+
|
|
12
|
+
onDelete: function (map) {
|
|
13
|
+
map.off('zoomend', this.onZoomEnd, this)
|
|
14
|
+
},
|
|
15
|
+
|
|
16
|
+
onAdd: function (map) {
|
|
17
|
+
map.on('moveend', this.onMoveEnd, this)
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
onRemove: function (map) {
|
|
21
|
+
map.off('moveend', this.onMoveEnd, this)
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
getType: function () {
|
|
25
|
+
const proto = Object.getPrototypeOf(this)
|
|
26
|
+
return proto.constructor.TYPE
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
getName: function () {
|
|
30
|
+
const proto = Object.getPrototypeOf(this)
|
|
31
|
+
return proto.constructor.NAME
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
getFeatures: function () {
|
|
35
|
+
return this._layers
|
|
36
|
+
},
|
|
37
|
+
|
|
38
|
+
getEditableOptions: () => [],
|
|
39
|
+
|
|
40
|
+
onEdit: () => {},
|
|
41
|
+
|
|
42
|
+
hasDataVisible: function () {
|
|
43
|
+
return !!Object.keys(this._layers).length
|
|
44
|
+
},
|
|
45
|
+
|
|
46
|
+
// Called when data changed on the datalayer
|
|
47
|
+
dataChanged: () => {},
|
|
48
|
+
|
|
49
|
+
onMoveEnd: function () {
|
|
50
|
+
if (this.datalayer.hasDynamicData() && this.datalayer.showAtZoom()) {
|
|
51
|
+
this.datalayer.fetchRemoteData()
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
onZoomEnd() {
|
|
56
|
+
if (this.datalayer._forcedVisibility) return
|
|
57
|
+
if (!this.datalayer.showAtZoom() && this.datalayer.isVisible()) {
|
|
58
|
+
this.datalayer.hide()
|
|
59
|
+
}
|
|
60
|
+
if (this.datalayer.showAtZoom() && !this.datalayer.isVisible()) {
|
|
61
|
+
this.datalayer.show()
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export const Default = FeatureGroup.extend({
|
|
67
|
+
statics: {
|
|
68
|
+
NAME: translate('Default'),
|
|
69
|
+
TYPE: 'Default',
|
|
70
|
+
},
|
|
71
|
+
includes: [LayerMixin],
|
|
72
|
+
|
|
73
|
+
initialize: function (datalayer) {
|
|
74
|
+
this.datalayer = datalayer
|
|
75
|
+
FeatureGroup.prototype.initialize.call(this)
|
|
76
|
+
LayerMixin.onInit.call(this, this.datalayer.map)
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
onAdd: function (map) {
|
|
80
|
+
LayerMixin.onAdd.call(this, map)
|
|
81
|
+
return FeatureGroup.prototype.onAdd.call(this, map)
|
|
82
|
+
},
|
|
83
|
+
|
|
84
|
+
onRemove: function (map) {
|
|
85
|
+
LayerMixin.onRemove.call(this, map)
|
|
86
|
+
return FeatureGroup.prototype.onRemove.call(this, map)
|
|
87
|
+
},
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
TileLayer.include({
|
|
91
|
+
toJSON() {
|
|
92
|
+
return {
|
|
93
|
+
minZoom: this.options.minZoom,
|
|
94
|
+
maxZoom: this.options.maxZoom,
|
|
95
|
+
attribution: this.options.attribution,
|
|
96
|
+
url_template: this._url,
|
|
97
|
+
name: this.options.name,
|
|
98
|
+
tms: this.options.tms,
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
|
|
102
|
+
getAttribution() {
|
|
103
|
+
return Utils.toHTML(this.options.attribution)
|
|
104
|
+
},
|
|
105
|
+
})
|