umap-project 3.0.3__py3-none-any.whl → 3.0.5__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 +136 -56
- umap/locale/en/LC_MESSAGES/django.po +18 -18
- umap/locale/es/LC_MESSAGES/django.mo +0 -0
- umap/locale/es/LC_MESSAGES/django.po +136 -56
- umap/locale/nl/LC_MESSAGES/django.mo +0 -0
- umap/locale/nl/LC_MESSAGES/django.po +1 -1
- umap/models.py +1 -0
- umap/settings/base.py +1 -0
- umap/static/umap/css/bar.css +1 -1
- umap/static/umap/css/form.css +44 -44
- umap/static/umap/css/tooltip.css +13 -0
- umap/static/umap/js/modules/autocomplete.js +7 -8
- umap/static/umap/js/modules/browser.js +89 -94
- umap/static/umap/js/modules/caption.js +6 -4
- umap/static/umap/js/modules/data/features.js +1 -19
- umap/static/umap/js/modules/data/layer.js +100 -61
- umap/static/umap/js/modules/facets.js +1 -1
- umap/static/umap/js/modules/form/fields.js +1 -1
- umap/static/umap/js/modules/importer.js +1 -1
- umap/static/umap/js/modules/managers.js +46 -0
- umap/static/umap/js/modules/permissions.js +1 -1
- umap/static/umap/js/modules/rendering/controls.js +251 -0
- umap/static/umap/js/modules/rendering/layers/heat.js +5 -0
- umap/static/umap/js/modules/rendering/map.js +21 -10
- umap/static/umap/js/modules/rendering/ui.js +0 -1
- umap/static/umap/js/modules/rules.js +56 -46
- umap/static/umap/js/modules/schema.js +5 -1
- umap/static/umap/js/modules/share.js +2 -2
- umap/static/umap/js/modules/slideshow.js +1 -1
- umap/static/umap/js/modules/sync/engine.js +23 -9
- umap/static/umap/js/modules/ui/bar.js +2 -2
- umap/static/umap/js/modules/ui/base.js +13 -0
- umap/static/umap/js/modules/umap.js +70 -113
- umap/static/umap/js/umap.controls.js +0 -310
- umap/static/umap/js/umap.core.js +0 -40
- umap/static/umap/locale/am_ET.js +8 -3
- umap/static/umap/locale/am_ET.json +8 -3
- umap/static/umap/locale/ar.js +8 -3
- umap/static/umap/locale/ar.json +8 -3
- umap/static/umap/locale/ast.js +8 -3
- umap/static/umap/locale/ast.json +8 -3
- umap/static/umap/locale/bg.js +8 -3
- umap/static/umap/locale/bg.json +8 -3
- umap/static/umap/locale/br.js +8 -3
- umap/static/umap/locale/br.json +8 -3
- umap/static/umap/locale/ca.js +27 -22
- umap/static/umap/locale/ca.json +27 -22
- umap/static/umap/locale/cs_CZ.js +5 -2
- umap/static/umap/locale/cs_CZ.json +5 -2
- umap/static/umap/locale/da.js +8 -3
- umap/static/umap/locale/da.json +8 -3
- umap/static/umap/locale/de.js +5 -2
- umap/static/umap/locale/de.json +5 -2
- umap/static/umap/locale/el.js +92 -87
- umap/static/umap/locale/el.json +92 -87
- umap/static/umap/locale/en.js +5 -2
- umap/static/umap/locale/en.json +5 -2
- umap/static/umap/locale/en_US.json +8 -3
- umap/static/umap/locale/es.js +18 -15
- umap/static/umap/locale/es.json +18 -15
- umap/static/umap/locale/et.js +8 -3
- umap/static/umap/locale/et.json +8 -3
- umap/static/umap/locale/eu.js +5 -2
- umap/static/umap/locale/eu.json +5 -2
- umap/static/umap/locale/fa_IR.js +5 -2
- umap/static/umap/locale/fa_IR.json +5 -2
- umap/static/umap/locale/fi.js +8 -3
- umap/static/umap/locale/fi.json +8 -3
- umap/static/umap/locale/fr.js +5 -2
- umap/static/umap/locale/fr.json +5 -2
- umap/static/umap/locale/gl.js +5 -2
- umap/static/umap/locale/gl.json +5 -2
- umap/static/umap/locale/he.js +8 -3
- umap/static/umap/locale/he.json +8 -3
- umap/static/umap/locale/hr.js +8 -3
- umap/static/umap/locale/hr.json +8 -3
- umap/static/umap/locale/hu.js +5 -2
- umap/static/umap/locale/hu.json +5 -2
- umap/static/umap/locale/id.js +8 -3
- umap/static/umap/locale/id.json +8 -3
- umap/static/umap/locale/is.js +8 -3
- umap/static/umap/locale/is.json +8 -3
- umap/static/umap/locale/it.js +5 -2
- umap/static/umap/locale/it.json +5 -2
- umap/static/umap/locale/ja.js +8 -3
- umap/static/umap/locale/ja.json +8 -3
- umap/static/umap/locale/ko.js +8 -3
- umap/static/umap/locale/ko.json +8 -3
- umap/static/umap/locale/lt.js +8 -3
- umap/static/umap/locale/lt.json +8 -3
- umap/static/umap/locale/ms.js +8 -3
- umap/static/umap/locale/ms.json +8 -3
- umap/static/umap/locale/nl.js +7 -4
- umap/static/umap/locale/nl.json +7 -4
- umap/static/umap/locale/no.js +8 -3
- umap/static/umap/locale/no.json +8 -3
- umap/static/umap/locale/pl.js +8 -3
- umap/static/umap/locale/pl.json +8 -3
- umap/static/umap/locale/pl_PL.json +8 -3
- umap/static/umap/locale/pt.js +5 -2
- umap/static/umap/locale/pt.json +5 -2
- umap/static/umap/locale/pt_BR.js +8 -3
- umap/static/umap/locale/pt_BR.json +8 -3
- umap/static/umap/locale/pt_PT.js +5 -2
- umap/static/umap/locale/pt_PT.json +5 -2
- umap/static/umap/locale/ro.js +8 -3
- umap/static/umap/locale/ro.json +8 -3
- umap/static/umap/locale/ru.js +8 -3
- umap/static/umap/locale/ru.json +8 -3
- umap/static/umap/locale/sk_SK.js +8 -3
- umap/static/umap/locale/sk_SK.json +8 -3
- umap/static/umap/locale/sl.js +8 -3
- umap/static/umap/locale/sl.json +8 -3
- umap/static/umap/locale/sr.js +8 -3
- umap/static/umap/locale/sr.json +8 -3
- umap/static/umap/locale/sv.js +8 -3
- umap/static/umap/locale/sv.json +8 -3
- umap/static/umap/locale/th_TH.js +8 -3
- umap/static/umap/locale/th_TH.json +8 -3
- umap/static/umap/locale/tr.js +8 -3
- umap/static/umap/locale/tr.json +8 -3
- umap/static/umap/locale/uk_UA.js +8 -3
- umap/static/umap/locale/uk_UA.json +8 -3
- umap/static/umap/locale/vi.js +8 -3
- umap/static/umap/locale/vi.json +8 -3
- umap/static/umap/locale/vi_VN.json +8 -3
- umap/static/umap/locale/zh.js +8 -3
- umap/static/umap/locale/zh.json +8 -3
- umap/static/umap/locale/zh_CN.json +8 -3
- umap/static/umap/locale/zh_TW.Big5.json +8 -3
- umap/static/umap/locale/zh_TW.js +5 -2
- umap/static/umap/locale/zh_TW.json +5 -2
- umap/static/umap/map.css +11 -33
- umap/static/umap/vars.css +4 -0
- umap/static/umap/vendors/togeojson/togeojson.es.js +350 -177
- umap/static/umap/vendors/togeojson/togeojson.es.mjs.map +1 -1
- umap/templates/umap/design_system.html +355 -0
- umap/tests/base.py +2 -2
- umap/tests/fixtures/heatmap_data.json +1044 -0
- umap/tests/integration/test_browser.py +3 -3
- umap/tests/integration/test_conditional_rules.py +2 -2
- umap/tests/integration/test_datalayer.py +0 -1
- umap/tests/integration/test_edit_map.py +7 -7
- umap/tests/integration/test_facets_browser.py +2 -2
- umap/tests/integration/test_heatmap.py +41 -0
- umap/tests/integration/test_iframe.py +25 -0
- umap/tests/integration/test_import.py +58 -1
- umap/tests/integration/test_map.py +7 -8
- umap/tests/integration/test_optimistic_merge.py +12 -4
- umap/tests/integration/test_querystring.py +1 -1
- umap/tests/integration/test_remote_data.py +79 -0
- umap/tests/integration/test_websocket_sync.py +2 -2
- umap/urls.py +1 -0
- umap/views.py +7 -0
- {umap_project-3.0.3.dist-info → umap_project-3.0.5.dist-info}/METADATA +8 -8
- {umap_project-3.0.3.dist-info → umap_project-3.0.5.dist-info}/RECORD +161 -154
- {umap_project-3.0.3.dist-info → umap_project-3.0.5.dist-info}/WHEEL +0 -0
- {umap_project-3.0.3.dist-info → umap_project-3.0.5.dist-info}/entry_points.txt +0 -0
- {umap_project-3.0.3.dist-info → umap_project-3.0.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -33,6 +33,7 @@ import { EditPanel, FullPanel, Panel } from './ui/panel.js'
|
|
|
33
33
|
import Tooltip from './ui/tooltip.js'
|
|
34
34
|
import URLs from './urls.js'
|
|
35
35
|
import * as Utils from './utils.js'
|
|
36
|
+
import { DataLayerManager } from './managers.js'
|
|
36
37
|
|
|
37
38
|
export default class Umap {
|
|
38
39
|
constructor(element, geojson) {
|
|
@@ -107,8 +108,8 @@ export default class Umap {
|
|
|
107
108
|
if (geojson.properties.schema) this.overrideSchema(geojson.properties.schema)
|
|
108
109
|
|
|
109
110
|
// Do not display in an iframe.
|
|
110
|
-
if (
|
|
111
|
-
|
|
111
|
+
if (this.isEmbed) {
|
|
112
|
+
this.properties.homeControl = false
|
|
112
113
|
}
|
|
113
114
|
|
|
114
115
|
this._leafletMap.setup()
|
|
@@ -166,8 +167,7 @@ export default class Umap {
|
|
|
166
167
|
}
|
|
167
168
|
|
|
168
169
|
// Global storage for retrieving datalayers and features.
|
|
169
|
-
this.datalayers =
|
|
170
|
-
this.datalayersIndex = [] // Datalayers actually on the map and ordered.
|
|
170
|
+
this.datalayers = new DataLayerManager()
|
|
171
171
|
this.featuresIndex = {}
|
|
172
172
|
|
|
173
173
|
this.formatter = new Formatter(this)
|
|
@@ -217,7 +217,6 @@ export default class Umap {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
window.onbeforeunload = () => (this.editEnabled && this.isDirty) || null
|
|
220
|
-
this.backup()
|
|
221
220
|
}
|
|
222
221
|
|
|
223
222
|
get isDirty() {
|
|
@@ -258,6 +257,10 @@ export default class Umap {
|
|
|
258
257
|
}
|
|
259
258
|
}
|
|
260
259
|
|
|
260
|
+
get isEmbed() {
|
|
261
|
+
return window.self !== window.top
|
|
262
|
+
}
|
|
263
|
+
|
|
261
264
|
setPropertiesFromQueryString() {
|
|
262
265
|
const asBoolean = (key) => {
|
|
263
266
|
const value = this.searchParams.get(key)
|
|
@@ -612,7 +615,7 @@ export default class Umap {
|
|
|
612
615
|
this.datalayersLoaded = true
|
|
613
616
|
this.fire('datalayersloaded')
|
|
614
617
|
const toLoad = []
|
|
615
|
-
for (const datalayer of this.
|
|
618
|
+
for (const datalayer of this.datalayers.active()) {
|
|
616
619
|
if (datalayer.showAtLoad()) toLoad.push(() => datalayer.show())
|
|
617
620
|
}
|
|
618
621
|
while (toLoad.length) {
|
|
@@ -626,7 +629,7 @@ export default class Umap {
|
|
|
626
629
|
|
|
627
630
|
createDataLayer(options = {}, sync = true) {
|
|
628
631
|
options.name =
|
|
629
|
-
options.name || `${translate('Layer')} ${this.
|
|
632
|
+
options.name || `${translate('Layer')} ${this.datalayers.count() + 1}`
|
|
630
633
|
const datalayer = new DataLayer(this, this._leafletMap, options)
|
|
631
634
|
|
|
632
635
|
if (sync !== false) {
|
|
@@ -637,7 +640,6 @@ export default class Umap {
|
|
|
637
640
|
|
|
638
641
|
createDirtyDataLayer(options) {
|
|
639
642
|
const datalayer = this.createDataLayer(options, true)
|
|
640
|
-
datalayer.isDirty = true
|
|
641
643
|
return datalayer
|
|
642
644
|
}
|
|
643
645
|
|
|
@@ -647,19 +649,19 @@ export default class Umap {
|
|
|
647
649
|
}
|
|
648
650
|
|
|
649
651
|
reindexDataLayers() {
|
|
650
|
-
this.
|
|
652
|
+
this.datalayers.active().map((datalayer) => datalayer.reindex())
|
|
651
653
|
this.onDataLayersChanged()
|
|
652
654
|
}
|
|
653
655
|
|
|
654
|
-
|
|
655
|
-
const
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
656
|
+
reorderDataLayers() {
|
|
657
|
+
const parent = this._leafletMap.getPane('overlayPane')
|
|
658
|
+
const datalayers = Object.values(this.datalayers)
|
|
659
|
+
.filter((datalayer) => !datalayer._isDeleted)
|
|
660
|
+
.sort((datalayer1, datalayer2) => datalayer1.rank > datalayer2.rank)
|
|
661
|
+
for (const datalayer of datalayers) {
|
|
662
|
+
const child = parent.querySelector(`[data-id="${datalayer.id}"]`)
|
|
663
|
+
parent.appendChild(child)
|
|
661
664
|
}
|
|
662
|
-
this.onDataLayersChanged()
|
|
663
665
|
}
|
|
664
666
|
|
|
665
667
|
onceDatalayersLoaded(callback, context) {
|
|
@@ -690,8 +692,8 @@ export default class Umap {
|
|
|
690
692
|
async saveAll() {
|
|
691
693
|
if (!this.isDirty) return
|
|
692
694
|
if (this._defaultExtent) this._setCenterAndZoom()
|
|
693
|
-
this.
|
|
694
|
-
|
|
695
|
+
const status = await this.sync.save()
|
|
696
|
+
if (!status) return
|
|
695
697
|
// Do a blind render for now, as we are not sure what could
|
|
696
698
|
// have changed, we'll be more subtil when we'll remove the
|
|
697
699
|
// save action
|
|
@@ -709,24 +711,6 @@ export default class Umap {
|
|
|
709
711
|
return this.properties.name || translate('Untitled map')
|
|
710
712
|
}
|
|
711
713
|
|
|
712
|
-
backup() {
|
|
713
|
-
this.backupProperties()
|
|
714
|
-
this._datalayersIndex_bk = [].concat(this.datalayersIndex)
|
|
715
|
-
}
|
|
716
|
-
|
|
717
|
-
backupProperties() {
|
|
718
|
-
this._backupProperties = Object.assign({}, this.properties)
|
|
719
|
-
this._backupProperties.tilelayer = Object.assign({}, this.properties.tilelayer)
|
|
720
|
-
this._backupProperties.limitBounds = Object.assign({}, this.properties.limitBounds)
|
|
721
|
-
this._backupProperties.permissions = Object.assign({}, this.permissions.properties)
|
|
722
|
-
}
|
|
723
|
-
|
|
724
|
-
resetProperties() {
|
|
725
|
-
this.properties = Object.assign({}, this._backupProperties)
|
|
726
|
-
this.properties.tilelayer = Object.assign({}, this._backupProperties.tilelayer)
|
|
727
|
-
this.permissions.properties = Object.assign({}, this._backupProperties.permissions)
|
|
728
|
-
}
|
|
729
|
-
|
|
730
714
|
setProperties(newProperties) {
|
|
731
715
|
for (const key of Object.keys(SCHEMA)) {
|
|
732
716
|
if (newProperties[key] !== undefined) {
|
|
@@ -739,24 +723,24 @@ export default class Umap {
|
|
|
739
723
|
}
|
|
740
724
|
|
|
741
725
|
hasData() {
|
|
742
|
-
for (const datalayer of this.
|
|
726
|
+
for (const datalayer of this.datalayers.active()) {
|
|
743
727
|
if (datalayer.hasData()) return true
|
|
744
728
|
}
|
|
745
729
|
}
|
|
746
730
|
|
|
747
731
|
hasLayers() {
|
|
748
|
-
return Boolean(this.
|
|
732
|
+
return Boolean(this.datalayers.count())
|
|
749
733
|
}
|
|
750
734
|
|
|
751
735
|
allProperties() {
|
|
752
|
-
return [].concat(...this.
|
|
736
|
+
return [].concat(...this.datalayers.active().map((dl) => dl.allProperties()))
|
|
753
737
|
}
|
|
754
738
|
|
|
755
739
|
sortedValues(property) {
|
|
756
740
|
return []
|
|
757
|
-
.concat(...this.
|
|
741
|
+
.concat(...this.datalayers.active().map((dl) => dl.sortedValues(property)))
|
|
758
742
|
.filter((val, idx, arr) => arr.indexOf(val) === idx)
|
|
759
|
-
.sort(
|
|
743
|
+
.sort(Utils.naturalSort)
|
|
760
744
|
}
|
|
761
745
|
|
|
762
746
|
editCaption() {
|
|
@@ -819,7 +803,7 @@ export default class Umap {
|
|
|
819
803
|
`<button type="button">${translate('Use current center and zoom')}</button>`
|
|
820
804
|
)
|
|
821
805
|
button.addEventListener('click', () => {
|
|
822
|
-
this.
|
|
806
|
+
this.setCenterAndZoom()
|
|
823
807
|
builder.fetchAll()
|
|
824
808
|
})
|
|
825
809
|
container.appendChild(form)
|
|
@@ -833,7 +817,6 @@ export default class Umap {
|
|
|
833
817
|
UIFields.push(`properties.${name}Control`)
|
|
834
818
|
}
|
|
835
819
|
UIFields = UIFields.concat([
|
|
836
|
-
'properties.homeControl',
|
|
837
820
|
'properties.moreControl',
|
|
838
821
|
'properties.scrollWheelZoom',
|
|
839
822
|
'properties.miniMap',
|
|
@@ -1178,7 +1161,7 @@ export default class Umap {
|
|
|
1178
1161
|
}
|
|
1179
1162
|
this._advancedActions(container)
|
|
1180
1163
|
|
|
1181
|
-
this.editPanel.open({
|
|
1164
|
+
return this.editPanel.open({
|
|
1182
1165
|
content: container,
|
|
1183
1166
|
className: 'dark',
|
|
1184
1167
|
highlight: 'settings',
|
|
@@ -1232,12 +1215,8 @@ export default class Umap {
|
|
|
1232
1215
|
})
|
|
1233
1216
|
}
|
|
1234
1217
|
} else {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
// but update in case some other editors changed them in the meantime.
|
|
1238
|
-
this.permissions.setProperties(data.permissions)
|
|
1239
|
-
this.permissions.commit()
|
|
1240
|
-
}
|
|
1218
|
+
this.permissions.setProperties(data.permissions)
|
|
1219
|
+
this.permissions.commit()
|
|
1241
1220
|
this._leafletMap.once('saved', () => {
|
|
1242
1221
|
Alert.success(data.info || translate('Map has been saved!'))
|
|
1243
1222
|
})
|
|
@@ -1274,7 +1253,7 @@ export default class Umap {
|
|
|
1274
1253
|
|
|
1275
1254
|
toGeoJSON() {
|
|
1276
1255
|
let features = []
|
|
1277
|
-
this.
|
|
1256
|
+
this.datalayers.active().map((datalayer) => {
|
|
1278
1257
|
if (datalayer.isVisible()) {
|
|
1279
1258
|
features = features.concat(datalayer.featuresToGeoJSON())
|
|
1280
1259
|
}
|
|
@@ -1350,13 +1329,20 @@ export default class Umap {
|
|
|
1350
1329
|
if (fields.includes('properties.rules')) {
|
|
1351
1330
|
this.rules.load()
|
|
1352
1331
|
}
|
|
1353
|
-
this.
|
|
1332
|
+
this.datalayers.visible().map((datalayer) => {
|
|
1354
1333
|
datalayer.redraw()
|
|
1355
1334
|
})
|
|
1356
1335
|
break
|
|
1357
1336
|
case 'datalayer-index':
|
|
1358
1337
|
this.reindexDataLayers()
|
|
1359
1338
|
break
|
|
1339
|
+
case 'datalayer-rank':
|
|
1340
|
+
// When drag'n'dropping datalayers,
|
|
1341
|
+
// this get called once per datalayers.
|
|
1342
|
+
// (and same for undo/redo of the action)
|
|
1343
|
+
// TODO: call only once
|
|
1344
|
+
this.reorderDataLayers()
|
|
1345
|
+
break
|
|
1360
1346
|
case 'background':
|
|
1361
1347
|
this._leafletMap.initTileLayers()
|
|
1362
1348
|
break
|
|
@@ -1445,7 +1431,7 @@ export default class Umap {
|
|
|
1445
1431
|
) {
|
|
1446
1432
|
return datalayer
|
|
1447
1433
|
}
|
|
1448
|
-
datalayer = this.
|
|
1434
|
+
datalayer = this.datalayers.find((datalayer) => {
|
|
1449
1435
|
if (!datalayer.isDataReadOnly() && datalayer.isBrowsable()) {
|
|
1450
1436
|
fallback = datalayer
|
|
1451
1437
|
if (datalayer.isVisible()) return true
|
|
@@ -1460,61 +1446,37 @@ export default class Umap {
|
|
|
1460
1446
|
return this.createDirtyDataLayer()
|
|
1461
1447
|
}
|
|
1462
1448
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
if (
|
|
1466
|
-
return this.datalayersIndex[i]
|
|
1467
|
-
}
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
eachDataLayer(method, context) {
|
|
1472
|
-
for (let i = 0; i < this.datalayersIndex.length; i++) {
|
|
1473
|
-
method.call(context, this.datalayersIndex[i])
|
|
1474
|
-
}
|
|
1475
|
-
}
|
|
1476
|
-
|
|
1477
|
-
eachDataLayerReverse(method, context, filter) {
|
|
1478
|
-
for (let i = this.datalayersIndex.length - 1; i >= 0; i--) {
|
|
1479
|
-
if (filter && !filter.call(context, this.datalayersIndex[i])) continue
|
|
1480
|
-
method.call(context, this.datalayersIndex[i])
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
|
|
1484
|
-
eachBrowsableDataLayer(method, context) {
|
|
1485
|
-
this.eachDataLayerReverse(method, context, (d) => d.allowBrowse())
|
|
1486
|
-
}
|
|
1487
|
-
|
|
1488
|
-
eachVisibleDataLayer(method, context) {
|
|
1489
|
-
this.eachDataLayerReverse(method, context, (d) => d.isVisible())
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
eachFeature(callback, context) {
|
|
1493
|
-
this.eachBrowsableDataLayer((datalayer) => {
|
|
1494
|
-
if (datalayer.isVisible()) datalayer.eachFeature(callback, context)
|
|
1449
|
+
eachFeature(callback) {
|
|
1450
|
+
this.datalayers.browsable().map((datalayer) => {
|
|
1451
|
+
if (datalayer.isVisible()) datalayer.eachFeature(callback)
|
|
1495
1452
|
})
|
|
1496
1453
|
}
|
|
1497
1454
|
|
|
1498
1455
|
removeDataLayers() {
|
|
1499
|
-
this.
|
|
1456
|
+
this.datalayers.active().map((datalayer) => {
|
|
1500
1457
|
datalayer.del()
|
|
1501
1458
|
})
|
|
1502
1459
|
}
|
|
1503
1460
|
|
|
1504
1461
|
emptyDataLayers() {
|
|
1505
|
-
this.
|
|
1462
|
+
this.datalayers.active().map((datalayer) => {
|
|
1506
1463
|
datalayer.empty()
|
|
1507
1464
|
})
|
|
1508
1465
|
}
|
|
1509
1466
|
|
|
1510
1467
|
editDatalayers() {
|
|
1511
1468
|
if (!this.editEnabled) return
|
|
1512
|
-
const
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1469
|
+
const template = `
|
|
1470
|
+
<div>
|
|
1471
|
+
<h3><i class="icon icon-16 icon-layers"></i>${translate('Manage layers')}</h3>
|
|
1472
|
+
<ul data-ref=ul></ul>
|
|
1473
|
+
</div>
|
|
1474
|
+
`
|
|
1475
|
+
const [container, { ul }] = Utils.loadTemplateWithRefs(template)
|
|
1476
|
+
this.datalayers.reverse().map((datalayer) => {
|
|
1477
|
+
const row = Utils.loadTemplate(
|
|
1478
|
+
`<li class="orderable"><i class="icon icon-16 icon-drag" title="${translate('Drag to reorder')}"></i></li>`
|
|
1479
|
+
)
|
|
1518
1480
|
datalayer.renderToolbox(row)
|
|
1519
1481
|
const builder = new MutatingForm(
|
|
1520
1482
|
datalayer,
|
|
@@ -1525,20 +1487,27 @@ export default class Umap {
|
|
|
1525
1487
|
row.appendChild(form)
|
|
1526
1488
|
row.classList.toggle('off', !datalayer.isVisible())
|
|
1527
1489
|
row.dataset.id = datalayer.id
|
|
1490
|
+
ul.appendChild(row)
|
|
1528
1491
|
})
|
|
1529
1492
|
const onReorder = (src, dst, initialIndex, finalIndex) => {
|
|
1530
1493
|
const movedLayer = this.datalayers[src.dataset.id]
|
|
1531
1494
|
const targetLayer = this.datalayers[dst.dataset.id]
|
|
1532
|
-
const minIndex = Math.min(movedLayer.
|
|
1533
|
-
const maxIndex = Math.max(movedLayer.
|
|
1495
|
+
const minIndex = Math.min(movedLayer.getDOMOrder(), targetLayer.getDOMOrder())
|
|
1496
|
+
const maxIndex = Math.max(movedLayer.getDOMOrder(), targetLayer.getDOMOrder())
|
|
1534
1497
|
if (finalIndex === 0) movedLayer.bringToTop()
|
|
1535
1498
|
else if (finalIndex > initialIndex) movedLayer.insertBefore(targetLayer)
|
|
1536
1499
|
else movedLayer.insertAfter(targetLayer)
|
|
1537
|
-
this.
|
|
1538
|
-
|
|
1539
|
-
|
|
1500
|
+
this.sync.startBatch()
|
|
1501
|
+
this.datalayers.reverse().map((datalayer) => {
|
|
1502
|
+
const rank = datalayer.getDOMOrder()
|
|
1503
|
+
if (rank >= minIndex && rank <= maxIndex) {
|
|
1504
|
+
const oldRank = datalayer.rank
|
|
1505
|
+
datalayer.rank = rank
|
|
1506
|
+
datalayer.sync.update('options.rank', rank, oldRank)
|
|
1507
|
+
}
|
|
1540
1508
|
})
|
|
1541
|
-
this.
|
|
1509
|
+
this.sync.commitBatch()
|
|
1510
|
+
this.onDataLayersChanged()
|
|
1542
1511
|
}
|
|
1543
1512
|
const orderable = new Orderable(ul, onReorder)
|
|
1544
1513
|
|
|
@@ -1560,18 +1529,6 @@ export default class Umap {
|
|
|
1560
1529
|
return datalayer
|
|
1561
1530
|
}
|
|
1562
1531
|
|
|
1563
|
-
firstVisibleDatalayer() {
|
|
1564
|
-
return this.findDataLayer((datalayer) => {
|
|
1565
|
-
if (datalayer.isVisible()) return true
|
|
1566
|
-
})
|
|
1567
|
-
}
|
|
1568
|
-
|
|
1569
|
-
ensurePanesOrder() {
|
|
1570
|
-
this.eachDataLayer((datalayer) => {
|
|
1571
|
-
datalayer.bringToTop()
|
|
1572
|
-
})
|
|
1573
|
-
}
|
|
1574
|
-
|
|
1575
1532
|
openBrowser(mode) {
|
|
1576
1533
|
this.onceDatalayersLoaded(() => this.browser.open(mode))
|
|
1577
1534
|
}
|
|
@@ -1722,7 +1679,7 @@ export default class Umap {
|
|
|
1722
1679
|
|
|
1723
1680
|
getLayersBounds() {
|
|
1724
1681
|
const bounds = new latLngBounds()
|
|
1725
|
-
this.
|
|
1682
|
+
this.datalayers.browsable().map((d) => {
|
|
1726
1683
|
if (d.isVisible()) bounds.extend(d.layer.getBounds())
|
|
1727
1684
|
})
|
|
1728
1685
|
return bounds
|