mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
chore: apply Biome unsafe changes
Without `useBlockStatements`
This commit is contained in:
parent
88d1151972
commit
445a793c3e
29 changed files with 319 additions and 330 deletions
|
@ -13,7 +13,7 @@
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"rules": {
|
"rules": {
|
||||||
"style": {
|
"style": {
|
||||||
"useBlockStatements": "warn",
|
"useBlockStatements": "off",
|
||||||
"noShoutyConstants": "warn"
|
"noShoutyConstants": "warn"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -250,7 +250,7 @@ export class BaseAjax extends BaseAutocomplete {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (val === this.cache) return
|
if (val === this.cache) return
|
||||||
else this.cache = val
|
this.cache = val
|
||||||
val = val.toLowerCase()
|
val = val.toLowerCase()
|
||||||
const url = Util.template(this.url, { q: encodeURIComponent(val) })
|
const url = Util.template(this.url, { q: encodeURIComponent(val) })
|
||||||
this.handleResults(await this._search(url))
|
this.handleResults(await this._search(url))
|
||||||
|
@ -258,7 +258,7 @@ export class BaseAjax extends BaseAutocomplete {
|
||||||
|
|
||||||
async _search(url) {
|
async _search(url) {
|
||||||
const response = await this.request.get(url)
|
const response = await this.request.get(url)
|
||||||
if (response && response.ok) {
|
if (response?.ok) {
|
||||||
return await response.json()
|
return await response.json()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,8 +63,8 @@ export default class Browser {
|
||||||
addDataLayer(datalayer, parent) {
|
addDataLayer(datalayer, parent) {
|
||||||
let className = `datalayer ${datalayer.getHidableClass()}`
|
let className = `datalayer ${datalayer.getHidableClass()}`
|
||||||
if (this.mode !== 'layers') className += ' show-list'
|
if (this.mode !== 'layers') className += ' show-list'
|
||||||
const container = DomUtil.create('div', className, parent),
|
const container = DomUtil.create('div', className, parent)
|
||||||
headline = DomUtil.create('h5', '', container)
|
const headline = DomUtil.create('h5', '', container)
|
||||||
container.id = this.datalayerId(datalayer)
|
container.id = this.datalayerId(datalayer)
|
||||||
const ul = DomUtil.create('ul', '', container)
|
const ul = DomUtil.create('ul', '', container)
|
||||||
this.updateDatalayer(datalayer)
|
this.updateDatalayer(datalayer)
|
||||||
|
@ -90,9 +90,9 @@ export default class Browser {
|
||||||
container.innerHTML = ''
|
container.innerHTML = ''
|
||||||
datalayer.eachFeature((feature) => this.addFeature(feature, container))
|
datalayer.eachFeature((feature) => this.addFeature(feature, container))
|
||||||
|
|
||||||
const total = datalayer.count(),
|
const total = datalayer.count()
|
||||||
current = container.querySelectorAll('li').length,
|
const current = container.querySelectorAll('li').length
|
||||||
count = total == current ? total : `${current}/${total}`
|
const count = total === current ? total : `${current}/${total}`
|
||||||
const counter = DomUtil.create('span', 'datalayer-counter', headline)
|
const counter = DomUtil.create('span', 'datalayer-counter', headline)
|
||||||
counter.textContent = `(${count})`
|
counter.textContent = `(${count})`
|
||||||
counter.title = translate(`Features in this layer: ${count}`)
|
counter.title = translate(`Features in this layer: ${count}`)
|
||||||
|
|
|
@ -40,9 +40,9 @@ export default class Caption {
|
||||||
|
|
||||||
addDataLayer(datalayer, container) {
|
addDataLayer(datalayer, container) {
|
||||||
if (!datalayer.options.inCaption) return
|
if (!datalayer.options.inCaption) return
|
||||||
const p = DomUtil.create('p', 'datalayer-legend', container),
|
const p = DomUtil.create('p', 'datalayer-legend', container)
|
||||||
legend = DomUtil.create('span', '', p),
|
const legend = DomUtil.create('span', '', p)
|
||||||
headline = DomUtil.create('strong', '', p)
|
const headline = DomUtil.create('strong', '', p)
|
||||||
datalayer.onceLoaded(() => {
|
datalayer.onceLoaded(() => {
|
||||||
datalayer.renderLegend(legend)
|
datalayer.renderLegend(legend)
|
||||||
if (datalayer.options.description) {
|
if (datalayer.options.description) {
|
||||||
|
|
|
@ -6,7 +6,6 @@ console.log(DOMPurifyInitializer)
|
||||||
export default function getPurify() {
|
export default function getPurify() {
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
return DOMPurifyInitializer(new JSDOM('').window)
|
return DOMPurifyInitializer(new JSDOM('').window)
|
||||||
} else {
|
|
||||||
return DOMPurifyInitializer(window)
|
|
||||||
}
|
}
|
||||||
|
return DOMPurifyInitializer(window)
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ export default class Facets {
|
||||||
let selected
|
let selected
|
||||||
|
|
||||||
names.forEach((name) => {
|
names.forEach((name) => {
|
||||||
const type = defined[name]['type']
|
const type = defined[name].type
|
||||||
properties[name] = { type: type }
|
properties[name] = { type: type }
|
||||||
selected = this.selected[name] || {}
|
selected = this.selected[name] || {}
|
||||||
selected.type = type
|
selected.type = type
|
||||||
|
@ -28,18 +28,24 @@ export default class Facets {
|
||||||
datalayer.eachFeature((feature) => {
|
datalayer.eachFeature((feature) => {
|
||||||
names.forEach((name) => {
|
names.forEach((name) => {
|
||||||
let value = feature.properties[name]
|
let value = feature.properties[name]
|
||||||
const type = defined[name]['type']
|
const type = defined[name].type
|
||||||
const parser = this.getParser(type)
|
const parser = this.getParser(type)
|
||||||
value = parser(value)
|
value = parser(value)
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'date':
|
case 'date':
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
case 'number':
|
case 'number':
|
||||||
if (!isNaN(value)) {
|
if (!Number.isNaN(value)) {
|
||||||
if (isNaN(properties[name].min) || properties[name].min > value) {
|
if (
|
||||||
|
Number.isNaN(properties[name].min) ||
|
||||||
|
properties[name].min > value
|
||||||
|
) {
|
||||||
properties[name].min = value
|
properties[name].min = value
|
||||||
}
|
}
|
||||||
if (isNaN(properties[name].max) || properties[name].max < value) {
|
if (
|
||||||
|
Number.isNaN(properties[name].max) ||
|
||||||
|
properties[name].max < value
|
||||||
|
) {
|
||||||
properties[name].max = value
|
properties[name].max = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +64,7 @@ export default class Facets {
|
||||||
|
|
||||||
isActive() {
|
isActive() {
|
||||||
for (const { type, min, max, choices } of Object.values(this.selected)) {
|
for (const { type, min, max, choices } of Object.values(this.selected)) {
|
||||||
if (min !== undefined || max != undefined || choices?.length) {
|
if (min !== undefined || max !== undefined || choices?.length) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +79,7 @@ export default class Facets {
|
||||||
const fields = names.map((name) => {
|
const fields = names.map((name) => {
|
||||||
const criteria = facetProperties[name]
|
const criteria = facetProperties[name]
|
||||||
let handler = 'FacetSearchChoices'
|
let handler = 'FacetSearchChoices'
|
||||||
switch (criteria['type']) {
|
switch (criteria.type) {
|
||||||
case 'number':
|
case 'number':
|
||||||
handler = 'FacetSearchNumber'
|
handler = 'FacetSearchNumber'
|
||||||
break
|
break
|
||||||
|
@ -84,7 +90,7 @@ export default class Facets {
|
||||||
handler = 'FacetSearchDateTime'
|
handler = 'FacetSearchDateTime'
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
const label = defined[name]['label']
|
const label = defined[name].label
|
||||||
return [
|
return [
|
||||||
`selected.${name}`,
|
`selected.${name}`,
|
||||||
{
|
{
|
||||||
|
|
|
@ -191,7 +191,7 @@ export default class Help {
|
||||||
const container = DomUtil.add('div')
|
const container = DomUtil.add('div')
|
||||||
DomUtil.createTitle(container, translate('Help'))
|
DomUtil.createTitle(container, translate('Help'))
|
||||||
// Special dynamic case. Do we still think this dialog is usefull ?
|
// Special dynamic case. Do we still think this dialog is usefull ?
|
||||||
if (entries == 'edit') {
|
if (entries === 'edit') {
|
||||||
DomUtil.element({
|
DomUtil.element({
|
||||||
tagName: 'div',
|
tagName: 'div',
|
||||||
className: 'umap-help-entry',
|
className: 'umap-help-entry',
|
||||||
|
|
|
@ -179,12 +179,12 @@ export default class Importer {
|
||||||
this.format === 'umap' || !this.url
|
this.format === 'umap' || !this.url
|
||||||
)
|
)
|
||||||
this.qs('[name=layer-name]').toggleAttribute('hidden', Boolean(this.layerId))
|
this.qs('[name=layer-name]').toggleAttribute('hidden', Boolean(this.layerId))
|
||||||
this.qs('#clear').toggleAttribute('hidden', !Boolean(this.layerId))
|
this.qs('#clear').toggleAttribute('hidden', !this.layerId)
|
||||||
}
|
}
|
||||||
|
|
||||||
onFileChange(e) {
|
onFileChange(e) {
|
||||||
let type = '',
|
let type = ''
|
||||||
newType
|
let newType
|
||||||
for (const file of e.target.files) {
|
for (const file of e.target.files) {
|
||||||
newType = U.Utils.detectFileType(file)
|
newType = U.Utils.detectFileType(file)
|
||||||
if (!type && newType) type = newType
|
if (!type && newType) type = newType
|
||||||
|
|
|
@ -52,7 +52,7 @@ export class Importer {
|
||||||
container.innerHTML = TEMPLATE
|
container.innerHTML = TEMPLATE
|
||||||
const response = await importer.map.request.get(`${this.baseUrl}/themes`)
|
const response = await importer.map.request.get(`${this.baseUrl}/themes`)
|
||||||
const select = container.querySelector('select')
|
const select = container.querySelector('select')
|
||||||
if (response && response.ok) {
|
if (response?.ok) {
|
||||||
const { themes } = await response.json()
|
const { themes } = await response.json()
|
||||||
themes.sort((a, b) => Utils.naturalSort(a['name:fr'], b['name:fr']))
|
themes.sort((a, b) => Utils.naturalSort(a['name:fr'], b['name:fr']))
|
||||||
for (const theme of themes) {
|
for (const theme of themes) {
|
||||||
|
|
|
@ -59,8 +59,8 @@ export default class Orderable {
|
||||||
const dst = this.findTarget(e.target)
|
const dst = this.findTarget(e.target)
|
||||||
if (!dst || dst === this.src) return
|
if (!dst || dst === this.src) return
|
||||||
this.dst = dst
|
this.dst = dst
|
||||||
const targetIndex = this.nodeIndex(this.dst),
|
const targetIndex = this.nodeIndex(this.dst)
|
||||||
srcIndex = this.nodeIndex(this.src)
|
const srcIndex = this.nodeIndex(this.src)
|
||||||
if (targetIndex > srcIndex) this.parent.insertBefore(this.dst, this.src)
|
if (targetIndex > srcIndex) this.parent.insertBefore(this.dst, this.src)
|
||||||
else this.parent.insertBefore(this.src, this.dst)
|
else this.parent.insertBefore(this.src, this.dst)
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,7 +49,7 @@ class Rule {
|
||||||
}
|
}
|
||||||
|
|
||||||
not_equal(other) {
|
not_equal(other) {
|
||||||
return this.expected != other
|
return this.expected !== other
|
||||||
}
|
}
|
||||||
|
|
||||||
gt(other) {
|
gt(other) {
|
||||||
|
@ -71,10 +71,10 @@ class Rule {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (vars.length != 2) return
|
if (vars.length !== 2) return
|
||||||
this.key = vars[0]
|
this.key = vars[0]
|
||||||
this.expected = vars[1]
|
this.expected = vars[1]
|
||||||
if (!isNaN(this.expected)) this.cast = Number.parseFloat
|
if (!Number.isNaN(this.expected)) this.cast = Number.parseFloat
|
||||||
else if (['true', 'false'].includes(this.expected)) this.cast = (v) => !!v
|
else if (['true', 'false'].includes(this.expected)) this.cast = (v) => !!v
|
||||||
this.expected = this.cast(this.expected)
|
this.expected = this.cast(this.expected)
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ class Rule {
|
||||||
}
|
}
|
||||||
|
|
||||||
_delete() {
|
_delete() {
|
||||||
this.map.rules.rules = this.map.rules.rules.filter((rule) => rule != this)
|
this.map.rules.rules = this.map.rules.rules.filter((rule) => rule !== this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,8 +181,8 @@ export default class Rules {
|
||||||
}
|
}
|
||||||
|
|
||||||
onReorder(src, dst, initialIndex, finalIndex) {
|
onReorder(src, dst, initialIndex, finalIndex) {
|
||||||
const moved = this.rules.find((rule) => stamp(rule) == src.dataset.id)
|
const moved = this.rules.find((rule) => stamp(rule) === src.dataset.id)
|
||||||
const reference = this.rules.find((rule) => stamp(rule) == dst.dataset.id)
|
const reference = this.rules.find((rule) => stamp(rule) === dst.dataset.id)
|
||||||
const movedIdx = this.rules.indexOf(moved)
|
const movedIdx = this.rules.indexOf(moved)
|
||||||
let referenceIdx = this.rules.indexOf(reference)
|
let referenceIdx = this.rules.indexOf(reference)
|
||||||
const minIndex = Math.min(movedIdx, referenceIdx)
|
const minIndex = Math.min(movedIdx, referenceIdx)
|
||||||
|
|
|
@ -36,7 +36,7 @@ export class SyncEngine {
|
||||||
|
|
||||||
// This method is called by the transport layer on new messages
|
// This method is called by the transport layer on new messages
|
||||||
receive({ kind, ...payload }) {
|
receive({ kind, ...payload }) {
|
||||||
if (kind == 'operation') {
|
if (kind === 'operation') {
|
||||||
const updater = this._getUpdater(payload.subject, payload.metadata)
|
const updater = this._getUpdater(payload.subject, payload.metadata)
|
||||||
updater.applyMessage(payload)
|
updater.applyMessage(payload)
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -89,9 +89,10 @@ export class FeatureUpdater extends BaseUpdater {
|
||||||
console.error(`Unable to find feature with id = ${metadata.id}.`)
|
console.error(`Unable to find feature with id = ${metadata.id}.`)
|
||||||
}
|
}
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case 'geometry':
|
case 'geometry': {
|
||||||
const datalayer = this.getDataLayerFromID(metadata.layerId)
|
const datalayer = this.getDataLayerFromID(metadata.layerId)
|
||||||
datalayer.geoJSONToLeaflet({ geometry: value, id: metadata.id, feature })
|
datalayer.geoJSONToLeaflet({ geometry: value, id: metadata.id, feature })
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
this.updateObjectValue(feature, key, value)
|
this.updateObjectValue(feature, key, value)
|
||||||
feature.datalayer.indexProperties(feature)
|
feature.datalayer.indexProperties(feature)
|
||||||
|
|
|
@ -44,8 +44,8 @@ export default class Tooltip {
|
||||||
const left =
|
const left =
|
||||||
this.parent.offsetLeft +
|
this.parent.offsetLeft +
|
||||||
this.parent.clientWidth / 2 -
|
this.parent.clientWidth / 2 -
|
||||||
this.container.clientWidth / 2,
|
this.container.clientWidth / 2
|
||||||
top = this.parent.offsetTop + 75
|
const top = this.parent.offsetTop + 75
|
||||||
this.setPosition({ top: top, left: left })
|
this.setPosition({ top: top, left: left })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,9 +10,8 @@ export default class URLs {
|
||||||
|
|
||||||
if (this.urls.hasOwnProperty(urlName)) {
|
if (this.urls.hasOwnProperty(urlName)) {
|
||||||
return template(this.urls[urlName], params)
|
return template(this.urls[urlName], params)
|
||||||
} else {
|
|
||||||
throw `Unable to find a URL for route ${urlName}`
|
|
||||||
}
|
}
|
||||||
|
throw `Unable to find a URL for route ${urlName}`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update if map_id is passed, create otherwise.
|
// Update if map_id is passed, create otherwise.
|
||||||
|
|
|
@ -63,9 +63,8 @@ export function getImpactsFromSchema(fields, schema) {
|
||||||
export default function getPurify() {
|
export default function getPurify() {
|
||||||
if (typeof window === 'undefined') {
|
if (typeof window === 'undefined') {
|
||||||
return DOMPurifyInitializer(new global.JSDOM('').window)
|
return DOMPurifyInitializer(new global.JSDOM('').window)
|
||||||
} else {
|
|
||||||
return DOMPurifyInitializer(window)
|
|
||||||
}
|
}
|
||||||
|
return DOMPurifyInitializer(window)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function escapeHTML(s) {
|
export function escapeHTML(s) {
|
||||||
|
@ -114,7 +113,7 @@ export function escapeHTML(s) {
|
||||||
|
|
||||||
export function toHTML(r, options) {
|
export function toHTML(r, options) {
|
||||||
if (!r) return ''
|
if (!r) return ''
|
||||||
const target = (options && options.target) || 'blank'
|
const target = options?.target || 'blank'
|
||||||
|
|
||||||
// unordered lists
|
// unordered lists
|
||||||
r = r.replace(/^\*\* (.*)/gm, '<ul><ul><li>$1</li></ul></ul>')
|
r = r.replace(/^\*\* (.*)/gm, '<ul><ul><li>$1</li></ul></ul>')
|
||||||
|
@ -271,8 +270,8 @@ export function sortFeatures(features, sortKey, lang) {
|
||||||
const sortKeys = (sortKey || 'name').split(',')
|
const sortKeys = (sortKey || 'name').split(',')
|
||||||
|
|
||||||
const sort = (a, b, i) => {
|
const sort = (a, b, i) => {
|
||||||
let sortKey = sortKeys[i],
|
let sortKey = sortKeys[i]
|
||||||
reverse = 1
|
let reverse = 1
|
||||||
if (sortKey[0] === '-') {
|
if (sortKey[0] === '-') {
|
||||||
reverse = -1
|
reverse = -1
|
||||||
sortKey = sortKey.substring(1)
|
sortKey = sortKey.substring(1)
|
||||||
|
@ -315,19 +314,19 @@ export function getBaseUrl() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasVar(value) {
|
export function hasVar(value) {
|
||||||
return typeof value === 'string' && value.indexOf('{') != -1
|
return typeof value === 'string' && value.indexOf('{') !== -1
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isPath(value) {
|
export function isPath(value) {
|
||||||
return value && value.length && value.startsWith('/')
|
return value?.length && value.startsWith('/')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isRemoteUrl(value) {
|
export function isRemoteUrl(value) {
|
||||||
return value && value.length && value.startsWith('http')
|
return value?.length && value.startsWith('http')
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isDataImage(value) {
|
export function isDataImage(value) {
|
||||||
return value && value.length && value.startsWith('data:image')
|
return value?.length && value.startsWith('data:image')
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -349,15 +348,16 @@ export function normalize(s) {
|
||||||
|
|
||||||
// Vendorized from leaflet.utils
|
// Vendorized from leaflet.utils
|
||||||
// https://github.com/Leaflet/Leaflet/blob/108c6717b70f57c63645498f9bd66b6677758786/src/core/Util.js#L132-L151
|
// https://github.com/Leaflet/Leaflet/blob/108c6717b70f57c63645498f9bd66b6677758786/src/core/Util.js#L132-L151
|
||||||
var templateRe = /\{ *([\w_ -]+) *\}/g
|
const templateRe = /\{ *([\w_ -]+) *\}/g
|
||||||
|
|
||||||
export function template(str, data) {
|
export function template(str, data) {
|
||||||
return str.replace(templateRe, (str, key) => {
|
return str.replace(templateRe, (str, key) => {
|
||||||
var value = data[key]
|
let value = data[key]
|
||||||
|
|
||||||
if (value === undefined) {
|
if (value === undefined) {
|
||||||
throw new Error('No value provided for variable ' + str)
|
throw new Error(`No value provided for variable ${str}`)
|
||||||
} else if (typeof value === 'function') {
|
}
|
||||||
|
if (typeof value === 'function') {
|
||||||
value = value(data)
|
value = value(data)
|
||||||
}
|
}
|
||||||
return value
|
return value
|
||||||
|
|
|
@ -434,9 +434,9 @@ U.MoreControls = L.Control.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
toggle: function () {
|
toggle: function () {
|
||||||
const pos = this.getPosition(),
|
const pos = this.getPosition()
|
||||||
corner = this._map._controlCorners[pos],
|
const corner = this._map._controlCorners[pos]
|
||||||
className = 'umap-more-controls'
|
const className = 'umap-more-controls'
|
||||||
if (L.DomUtil.hasClass(corner, className)) L.DomUtil.removeClass(corner, className)
|
if (L.DomUtil.hasClass(corner, className)) L.DomUtil.removeClass(corner, className)
|
||||||
else L.DomUtil.addClass(corner, className)
|
else L.DomUtil.addClass(corner, className)
|
||||||
},
|
},
|
||||||
|
@ -456,8 +456,8 @@ U.PermanentCreditsControl = L.Control.extend({
|
||||||
const paragraphContainer = L.DomUtil.create(
|
const paragraphContainer = L.DomUtil.create(
|
||||||
'div',
|
'div',
|
||||||
'umap-permanent-credits-container'
|
'umap-permanent-credits-container'
|
||||||
),
|
)
|
||||||
creditsParagraph = L.DomUtil.create('p', '', paragraphContainer)
|
const creditsParagraph = L.DomUtil.create('p', '', paragraphContainer)
|
||||||
|
|
||||||
this.paragraphContainer = paragraphContainer
|
this.paragraphContainer = paragraphContainer
|
||||||
this.setCredits()
|
this.setCredits()
|
||||||
|
@ -745,7 +745,7 @@ const ControlsMixin = {
|
||||||
L.DomUtil.createLink(
|
L.DomUtil.createLink(
|
||||||
'umap-user',
|
'umap-user',
|
||||||
rightContainer,
|
rightContainer,
|
||||||
L._(`My Dashboard ({username})`, {
|
L._('My Dashboard ({username})', {
|
||||||
username: this.options.user.name,
|
username: this.options.user.name,
|
||||||
}),
|
}),
|
||||||
this.options.user.url
|
this.options.user.url
|
||||||
|
@ -832,10 +832,10 @@ const ControlsMixin = {
|
||||||
row.dataset.id = L.stamp(datalayer)
|
row.dataset.id = L.stamp(datalayer)
|
||||||
})
|
})
|
||||||
const onReorder = (src, dst, initialIndex, finalIndex) => {
|
const onReorder = (src, dst, initialIndex, finalIndex) => {
|
||||||
const layer = this.datalayers[src.dataset.id],
|
const layer = this.datalayers[src.dataset.id]
|
||||||
other = this.datalayers[dst.dataset.id],
|
const other = this.datalayers[dst.dataset.id]
|
||||||
minIndex = Math.min(layer.getRank(), other.getRank()),
|
const minIndex = Math.min(layer.getRank(), other.getRank())
|
||||||
maxIndex = Math.max(layer.getRank(), other.getRank())
|
const maxIndex = Math.max(layer.getRank(), other.getRank())
|
||||||
if (finalIndex === 0) layer.bringToTop()
|
if (finalIndex === 0) layer.bringToTop()
|
||||||
else if (finalIndex > initialIndex) layer.insertBefore(other)
|
else if (finalIndex > initialIndex) layer.insertBefore(other)
|
||||||
else layer.insertAfter(other)
|
else layer.insertAfter(other)
|
||||||
|
@ -948,10 +948,10 @@ U.TileLayerChooser = L.Control.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addTileLayerElement: function (tilelayer, options) {
|
addTileLayerElement: function (tilelayer, options) {
|
||||||
const selectedClass = this.map.hasLayer(tilelayer) ? 'selected' : '',
|
const selectedClass = this.map.hasLayer(tilelayer) ? 'selected' : ''
|
||||||
el = L.DomUtil.create('li', selectedClass, this._tilelayers_container),
|
const el = L.DomUtil.create('li', selectedClass, this._tilelayers_container)
|
||||||
img = L.DomUtil.create('img', '', el),
|
const img = L.DomUtil.create('img', '', el)
|
||||||
name = L.DomUtil.create('div', '', el)
|
const name = L.DomUtil.create('div', '', el)
|
||||||
img.src = U.Utils.template(tilelayer.options.url_template, this.map.demoTileInfos)
|
img.src = U.Utils.template(tilelayer.options.url_template, this.map.demoTileInfos)
|
||||||
img.loading = 'lazy'
|
img.loading = 'lazy'
|
||||||
name.textContent = tilelayer.options.name
|
name.textContent = tilelayer.options.name
|
||||||
|
@ -961,7 +961,7 @@ U.TileLayerChooser = L.Control.extend({
|
||||||
function () {
|
function () {
|
||||||
this.map.selectTileLayer(tilelayer)
|
this.map.selectTileLayer(tilelayer)
|
||||||
this.map._controls.tilelayers.setLayers()
|
this.map._controls.tilelayers.setLayers()
|
||||||
if (options && options.callback) options.callback(tilelayer)
|
if (options?.callback) options.callback(tilelayer)
|
||||||
},
|
},
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
|
@ -982,8 +982,8 @@ U.AttributionControl = L.Control.Attribution.extend({
|
||||||
this._container.innerHTML = ''
|
this._container.innerHTML = ''
|
||||||
const container = L.DomUtil.create('div', 'attribution-container', this._container)
|
const container = L.DomUtil.create('div', 'attribution-container', this._container)
|
||||||
container.innerHTML = credits
|
container.innerHTML = credits
|
||||||
const shortCredit = this._map.getOption('shortCredit'),
|
const shortCredit = this._map.getOption('shortCredit')
|
||||||
captionMenus = this._map.getOption('captionMenus')
|
const captionMenus = this._map.getOption('captionMenus')
|
||||||
if (shortCredit) {
|
if (shortCredit) {
|
||||||
L.DomUtil.element({
|
L.DomUtil.element({
|
||||||
tagName: 'span',
|
tagName: 'span',
|
||||||
|
@ -1310,7 +1310,7 @@ U.Editable = L.Editable.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
drawingTooltip: function (e) {
|
drawingTooltip: function (e) {
|
||||||
if (e.layer instanceof L.Marker && e.type == 'editable:drawing:start') {
|
if (e.layer instanceof L.Marker && e.type === 'editable:drawing:start') {
|
||||||
this.map.tooltip.open({ content: L._('Click to add a marker') })
|
this.map.tooltip.open({ content: L._('Click to add a marker') })
|
||||||
}
|
}
|
||||||
if (!(e.layer instanceof L.Polyline)) {
|
if (!(e.layer instanceof L.Polyline)) {
|
||||||
|
|
|
@ -27,8 +27,8 @@ L.Util.copyToClipboard = (textToCopy) => {
|
||||||
|
|
||||||
L.Util.queryString = (name, fallback) => {
|
L.Util.queryString = (name, fallback) => {
|
||||||
const decode = (s) => decodeURIComponent(s.replace(/\+/g, ' '))
|
const decode = (s) => decodeURIComponent(s.replace(/\+/g, ' '))
|
||||||
const qs = window.location.search.slice(1).split('&'),
|
const qs = window.location.search.slice(1).split('&')
|
||||||
qa = {}
|
const qa = {}
|
||||||
for (const i in qs) {
|
for (const i in qs) {
|
||||||
const key = qs[i].split('=')
|
const key = qs[i].split('=')
|
||||||
if (!key) continue
|
if (!key) continue
|
||||||
|
@ -49,12 +49,12 @@ L.Util.setFromQueryString = (options, name) => {
|
||||||
|
|
||||||
L.Util.setBooleanFromQueryString = (options, name) => {
|
L.Util.setBooleanFromQueryString = (options, name) => {
|
||||||
const value = L.Util.queryString(name)
|
const value = L.Util.queryString(name)
|
||||||
if (typeof value !== 'undefined') options[name] = value == '1' || value == 'true'
|
if (typeof value !== 'undefined') options[name] = value === '1' || value === 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
L.Util.setNumberFromQueryString = (options, name) => {
|
L.Util.setNumberFromQueryString = (options, name) => {
|
||||||
const value = +L.Util.queryString(name)
|
const value = +L.Util.queryString(name)
|
||||||
if (!isNaN(value)) options[name] = value
|
if (!Number.isNaN(value)) options[name] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
L.Util.setNullableBooleanFromQueryString = (options, name) => {
|
L.Util.setNullableBooleanFromQueryString = (options, name) => {
|
||||||
|
@ -192,7 +192,7 @@ L.DomUtil.after = (target, el) => {
|
||||||
// convert colour in range 0-255 to the modifier used within luminance calculation
|
// convert colour in range 0-255 to the modifier used within luminance calculation
|
||||||
L.DomUtil.colourMod = (colour) => {
|
L.DomUtil.colourMod = (colour) => {
|
||||||
const sRGB = colour / 255
|
const sRGB = colour / 255
|
||||||
let mod = Math.pow((sRGB + 0.055) / 1.055, 2.4)
|
let mod = ((sRGB + 0.055) / 1.055) ** 2.4
|
||||||
if (sRGB < 0.03928) mod = sRGB / 12.92
|
if (sRGB < 0.03928) mod = sRGB / 12.92
|
||||||
return mod
|
return mod
|
||||||
}
|
}
|
||||||
|
@ -251,9 +251,9 @@ L.DomEvent.once = (el, types, fn, context) => {
|
||||||
|
|
||||||
L.LatLng.prototype.isValid = function () {
|
L.LatLng.prototype.isValid = function () {
|
||||||
return (
|
return (
|
||||||
isFinite(this.lat) &&
|
Number.isFinite(this.lat) &&
|
||||||
Math.abs(this.lat) <= 90 &&
|
Math.abs(this.lat) <= 90 &&
|
||||||
isFinite(this.lng) &&
|
Number.isFinite(this.lng) &&
|
||||||
Math.abs(this.lng) <= 180
|
Math.abs(this.lng) <= 180
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,11 +34,11 @@ U.DataLayerPermissions = L.Class.extend({
|
||||||
selectOptions: this.datalayer.map.options.datalayer_edit_statuses,
|
selectOptions: this.datalayer.map.options.datalayer_edit_statuses,
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
],
|
]
|
||||||
builder = new U.FormBuilder(this, fields, {
|
const builder = new U.FormBuilder(this, fields, {
|
||||||
className: 'umap-form datalayer-permissions',
|
className: 'umap-form datalayer-permissions',
|
||||||
}),
|
})
|
||||||
form = builder.build()
|
const form = builder.build()
|
||||||
container.appendChild(form)
|
container.appendChild(form)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ U.FeatureMixin = {
|
||||||
preInit: () => {},
|
preInit: () => {},
|
||||||
|
|
||||||
isReadOnly: function () {
|
isReadOnly: function () {
|
||||||
return this.datalayer && this.datalayer.isDataReadOnly()
|
return this.datalayer?.isDataReadOnly()
|
||||||
},
|
},
|
||||||
|
|
||||||
getSlug: function () {
|
getSlug: function () {
|
||||||
|
@ -312,7 +312,7 @@ U.FeatureMixin = {
|
||||||
// Retrocompat
|
// Retrocompat
|
||||||
if (this.properties._umap_options.clickable === false) {
|
if (this.properties._umap_options.clickable === false) {
|
||||||
this.properties._umap_options.interactive = false
|
this.properties._umap_options.interactive = false
|
||||||
delete this.properties._umap_options.clickable
|
this.properties._umap_options.clickable = undefined
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -377,7 +377,7 @@ U.FeatureMixin = {
|
||||||
const properties = L.extend({}, this.properties)
|
const properties = L.extend({}, this.properties)
|
||||||
properties._umap_options = L.extend({}, properties._umap_options)
|
properties._umap_options = L.extend({}, properties._umap_options)
|
||||||
if (Object.keys && Object.keys(properties._umap_options).length === 0) {
|
if (Object.keys && Object.keys(properties._umap_options).length === 0) {
|
||||||
delete properties._umap_options // It can make a difference on big data sets
|
properties._umap_options = undefined // It can make a difference on big data sets
|
||||||
}
|
}
|
||||||
return properties
|
return properties
|
||||||
},
|
},
|
||||||
|
@ -396,7 +396,7 @@ U.FeatureMixin = {
|
||||||
const geojson = this.parentClass.prototype.toGeoJSON.call(this)
|
const geojson = this.parentClass.prototype.toGeoJSON.call(this)
|
||||||
geojson.properties = this.cloneProperties()
|
geojson.properties = this.cloneProperties()
|
||||||
geojson.id = this.id
|
geojson.id = this.id
|
||||||
delete geojson.properties._storage_options
|
geojson.properties._storage_options = undefined
|
||||||
return geojson
|
return geojson
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -406,7 +406,7 @@ U.FeatureMixin = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_onClick: function (e) {
|
_onClick: function (e) {
|
||||||
if (this.map.measureTools && this.map.measureTools.enabled()) return
|
if (this.map.measureTools?.enabled()) return
|
||||||
this._popupHandlersAdded = true // Prevent leaflet from managing event
|
this._popupHandlersAdded = true // Prevent leaflet from managing event
|
||||||
if (!this.map.editEnabled) {
|
if (!this.map.editEnabled) {
|
||||||
this.view(e)
|
this.view(e)
|
||||||
|
@ -468,7 +468,7 @@ U.FeatureMixin = {
|
||||||
let items = ['-']
|
let items = ['-']
|
||||||
if (this.map.editedFeature !== this) {
|
if (this.map.editedFeature !== this) {
|
||||||
items.push({
|
items.push({
|
||||||
text: L._('Edit this feature') + ' (⇧+Click)',
|
text: `${L._('Edit this feature')} (⇧+Click)`,
|
||||||
callback: this.edit,
|
callback: this.edit,
|
||||||
context: this,
|
context: this,
|
||||||
iconCls: 'umap-edit',
|
iconCls: 'umap-edit',
|
||||||
|
@ -537,7 +537,7 @@ U.FeatureMixin = {
|
||||||
}
|
}
|
||||||
keys = keys.split(',')
|
keys = keys.split(',')
|
||||||
for (let i = 0, value; i < keys.length; i++) {
|
for (let i = 0, value; i < keys.length; i++) {
|
||||||
value = (this.properties[keys[i]] || '') + ''
|
value = `${this.properties[keys[i]] || ''}`
|
||||||
if (value.toLowerCase().indexOf(filter) !== -1) return true
|
if (value.toLowerCase().indexOf(filter) !== -1) return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -553,8 +553,8 @@ U.FeatureMixin = {
|
||||||
case 'date':
|
case 'date':
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
case 'number':
|
case 'number':
|
||||||
if (!isNaN(min) && !isNaN(value) && min > value) return false
|
if (!Number.isNaN(min) && !Number.isNaN(value) && min > value) return false
|
||||||
if (!isNaN(max) && !isNaN(value) && max < value) return false
|
if (!Number.isNaN(max) && !Number.isNaN(value) && max < value) return false
|
||||||
break
|
break
|
||||||
default:
|
default:
|
||||||
value = value || L._('<empty value>')
|
value = value || L._('<empty value>')
|
||||||
|
@ -578,8 +578,8 @@ U.FeatureMixin = {
|
||||||
|
|
||||||
clone: function () {
|
clone: function () {
|
||||||
const geoJSON = this.toGeoJSON()
|
const geoJSON = this.toGeoJSON()
|
||||||
delete geoJSON.id
|
geoJSON.id = undefined
|
||||||
delete geoJSON.properties.id
|
geoJSON.properties.id = undefined
|
||||||
const layer = this.datalayer.geojsonToFeatures(geoJSON)
|
const layer = this.datalayer.geojsonToFeatures(geoJSON)
|
||||||
layer.isDirty = true
|
layer.isDirty = true
|
||||||
layer.edit()
|
layer.edit()
|
||||||
|
@ -650,11 +650,7 @@ U.Marker = L.Marker.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMouseOut: function () {
|
_onMouseOut: function () {
|
||||||
if (
|
if (this.dragging?._draggable && !this.dragging._draggable._moving) {
|
||||||
this.dragging &&
|
|
||||||
this.dragging._draggable &&
|
|
||||||
!this.dragging._draggable._moving
|
|
||||||
) {
|
|
||||||
// Do not disable if the mouse went out while dragging
|
// Do not disable if the mouse went out while dragging
|
||||||
this._disableDragging()
|
this._disableDragging()
|
||||||
}
|
}
|
||||||
|
@ -675,14 +671,14 @@ U.Marker = L.Marker.extend({
|
||||||
|
|
||||||
_disableDragging: function () {
|
_disableDragging: function () {
|
||||||
if (this.map.editEnabled) {
|
if (this.map.editEnabled) {
|
||||||
if (this.editor && this.editor.drawing) return // when creating a new marker, the mouse can trigger the mouseover/mouseout event
|
if (this.editor?.drawing) return // when creating a new marker, the mouse can trigger the mouseover/mouseout event
|
||||||
// do not listen to them
|
// do not listen to them
|
||||||
this.disableEdit()
|
this.disableEdit()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_redraw: function () {
|
_redraw: function () {
|
||||||
if (this.datalayer && this.datalayer.isVisible()) {
|
if (this.datalayer?.isVisible()) {
|
||||||
this._initIcon()
|
this._initIcon()
|
||||||
this.update()
|
this.update()
|
||||||
}
|
}
|
||||||
|
@ -697,8 +693,8 @@ U.Marker = L.Marker.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
_getTooltipAnchor: function () {
|
_getTooltipAnchor: function () {
|
||||||
const anchor = this.options.icon.options.tooltipAnchor.clone(),
|
const anchor = this.options.icon.options.tooltipAnchor.clone()
|
||||||
direction = this.getOption('labelDirection')
|
const direction = this.getOption('labelDirection')
|
||||||
if (direction === 'left') {
|
if (direction === 'left') {
|
||||||
anchor.x *= -1
|
anchor.x *= -1
|
||||||
} else if (direction === 'bottom') {
|
} else if (direction === 'bottom') {
|
||||||
|
@ -853,7 +849,7 @@ U.PathMixin = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_redraw: function () {
|
_redraw: function () {
|
||||||
if (this.datalayer && this.datalayer.isVisible()) {
|
if (this.datalayer?.isVisible()) {
|
||||||
this.setStyle()
|
this.setStyle()
|
||||||
this.resetTooltip()
|
this.resetTooltip()
|
||||||
}
|
}
|
||||||
|
@ -867,14 +863,14 @@ U.PathMixin = {
|
||||||
// this.map.on('showmeasure', this.showMeasureTooltip, this);
|
// this.map.on('showmeasure', this.showMeasureTooltip, this);
|
||||||
// this.map.on('hidemeasure', this.removeTooltip, this);
|
// this.map.on('hidemeasure', this.removeTooltip, this);
|
||||||
this.parentClass.prototype.onAdd.call(this, map)
|
this.parentClass.prototype.onAdd.call(this, map)
|
||||||
if (this.editing && this.editing.enabled()) this.editing.addHooks()
|
if (this.editing?.enabled()) this.editing.addHooks()
|
||||||
this.resetTooltip()
|
this.resetTooltip()
|
||||||
},
|
},
|
||||||
|
|
||||||
onRemove: function (map) {
|
onRemove: function (map) {
|
||||||
// this.map.off('showmeasure', this.showMeasureTooltip, this);
|
// this.map.off('showmeasure', this.showMeasureTooltip, this);
|
||||||
// this.map.off('hidemeasure', this.removeTooltip, this);
|
// this.map.off('hidemeasure', this.removeTooltip, this);
|
||||||
if (this.editing && this.editing.enabled()) this.editing.removeHooks()
|
if (this.editing?.enabled()) this.editing.removeHooks()
|
||||||
U.FeatureMixin.onRemove.call(this, map)
|
U.FeatureMixin.onRemove.call(this, map)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -896,7 +892,7 @@ U.PathMixin = {
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMouseOver: function () {
|
_onMouseOver: function () {
|
||||||
if (this.map.measureTools && this.map.measureTools.enabled()) {
|
if (this.map.measureTools?.enabled()) {
|
||||||
this.map.tooltip.open({ content: this.getMeasure(), anchor: this })
|
this.map.tooltip.open({ content: this.getMeasure(), anchor: this })
|
||||||
} else if (this.map.editEnabled && !this.map.editedFeature) {
|
} else if (this.map.editEnabled && !this.map.editedFeature) {
|
||||||
this.map.tooltip.open({ content: L._('Click to edit'), anchor: this })
|
this.map.tooltip.open({ content: L._('Click to edit'), anchor: this })
|
||||||
|
@ -1103,7 +1099,7 @@ U.Polyline = L.Polyline.extend({
|
||||||
U.Utils.flattenCoordinates(geojson.geometry.coordinates),
|
U.Utils.flattenCoordinates(geojson.geometry.coordinates),
|
||||||
]
|
]
|
||||||
|
|
||||||
delete geojson.id // delete the copied id, a new one will be generated.
|
geojson.id = undefined // delete the copied id, a new one will be generated.
|
||||||
|
|
||||||
const polygon = this.datalayer.geojsonToFeatures(geojson)
|
const polygon = this.datalayer.geojsonToFeatures(geojson)
|
||||||
polygon.edit()
|
polygon.edit()
|
||||||
|
@ -1142,11 +1138,11 @@ U.Polyline = L.Polyline.extend({
|
||||||
from.reverse()
|
from.reverse()
|
||||||
toMerge = [from, to]
|
toMerge = [from, to]
|
||||||
}
|
}
|
||||||
const a = toMerge[0],
|
const a = toMerge[0]
|
||||||
b = toMerge[1],
|
const b = toMerge[1]
|
||||||
p1 = this.map.latLngToContainerPoint(a[a.length - 1]),
|
const p1 = this.map.latLngToContainerPoint(a[a.length - 1])
|
||||||
p2 = this.map.latLngToContainerPoint(b[0]),
|
const p2 = this.map.latLngToContainerPoint(b[0])
|
||||||
tolerance = 5 // px on screen
|
const tolerance = 5 // px on screen
|
||||||
if (Math.abs(p1.x - p2.x) <= tolerance && Math.abs(p1.y - p2.y) <= tolerance) {
|
if (Math.abs(p1.x - p2.x) <= tolerance && Math.abs(p1.y - p2.y) <= tolerance) {
|
||||||
a.pop()
|
a.pop()
|
||||||
}
|
}
|
||||||
|
@ -1171,8 +1167,8 @@ U.Polyline = L.Polyline.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getVertexActions: function (e) {
|
getVertexActions: function (e) {
|
||||||
const actions = U.FeatureMixin.getVertexActions.call(this, e),
|
const actions = U.FeatureMixin.getVertexActions.call(this, e)
|
||||||
index = e.vertex.getIndex()
|
const index = e.vertex.getIndex()
|
||||||
if (index === 0 || index === e.vertex.getLastIndex())
|
if (index === 0 || index === e.vertex.getLastIndex())
|
||||||
actions.push(U.ContinueLineAction)
|
actions.push(U.ContinueLineAction)
|
||||||
else actions.push(U.SplitLineAction)
|
else actions.push(U.SplitLineAction)
|
||||||
|
@ -1214,8 +1210,8 @@ U.Polygon = L.Polygon.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getContextMenuEditItems: function (e) {
|
getContextMenuEditItems: function (e) {
|
||||||
const items = U.PathMixin.getContextMenuEditItems.call(this, e),
|
const items = U.PathMixin.getContextMenuEditItems.call(this, e)
|
||||||
shape = this.shapeAt(e.latlng)
|
const shape = this.shapeAt(e.latlng)
|
||||||
// No multi and no holes.
|
// No multi and no holes.
|
||||||
if (shape && !this.isMulti() && (L.LineUtil.isFlat(shape) || shape.length === 1)) {
|
if (shape && !this.isMulti() && (L.LineUtil.isFlat(shape) || shape.length === 1)) {
|
||||||
items.push({
|
items.push({
|
||||||
|
@ -1238,8 +1234,8 @@ U.Polygon = L.Polygon.extend({
|
||||||
|
|
||||||
toPolyline: function () {
|
toPolyline: function () {
|
||||||
const geojson = this.toGeoJSON()
|
const geojson = this.toGeoJSON()
|
||||||
delete geojson.id
|
geojson.id = undefined
|
||||||
delete geojson.properties.id
|
geojson.properties.id = undefined
|
||||||
geojson.geometry.type = 'LineString'
|
geojson.geometry.type = 'LineString'
|
||||||
geojson.geometry.coordinates = U.Utils.flattenCoordinates(
|
geojson.geometry.coordinates = U.Utils.flattenCoordinates(
|
||||||
geojson.geometry.coordinates
|
geojson.geometry.coordinates
|
||||||
|
|
|
@ -61,8 +61,8 @@ L.FormBuilder.Element.include({
|
||||||
|
|
||||||
get: function (own) {
|
get: function (own) {
|
||||||
if (!this.options.inheritable || own) return this.builder.getter(this.field)
|
if (!this.options.inheritable || own) return this.builder.getter(this.field)
|
||||||
const path = this.field.split('.'),
|
const path = this.field.split('.')
|
||||||
key = path[path.length - 1]
|
const key = path[path.length - 1]
|
||||||
return this.obj.getOption(key)
|
return this.obj.getOption(key)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -514,13 +514,8 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
|
||||||
this
|
this
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const symbol = L.DomUtil.add(
|
const symbol = L.DomUtil.add('button', 'flat tab-symbols', this.tabs, L._('Symbol'))
|
||||||
'button',
|
const char = L.DomUtil.add(
|
||||||
'flat tab-symbols',
|
|
||||||
this.tabs,
|
|
||||||
L._('Symbol')
|
|
||||||
),
|
|
||||||
char = L.DomUtil.add(
|
|
||||||
'button',
|
'button',
|
||||||
'flat tab-chars',
|
'flat tab-chars',
|
||||||
this.tabs,
|
this.tabs,
|
||||||
|
@ -571,15 +566,15 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addIconPreview: function (pictogram, parent) {
|
addIconPreview: function (pictogram, parent) {
|
||||||
const baseClass = 'umap-pictogram-choice',
|
const baseClass = 'umap-pictogram-choice'
|
||||||
value = pictogram.src,
|
const value = pictogram.src
|
||||||
search = U.Utils.normalize(this.searchInput.value),
|
const search = U.Utils.normalize(this.searchInput.value)
|
||||||
title = pictogram.attribution
|
const title = pictogram.attribution
|
||||||
? `${pictogram.name} — © ${pictogram.attribution}`
|
? `${pictogram.name} — © ${pictogram.attribution}`
|
||||||
: pictogram.name || pictogram.src
|
: pictogram.name || pictogram.src
|
||||||
if (search && U.Utils.normalize(title).indexOf(search) === -1) return
|
if (search && U.Utils.normalize(title).indexOf(search) === -1) return
|
||||||
const className = value === this.value() ? `${baseClass} selected` : baseClass,
|
const className = value === this.value() ? `${baseClass} selected` : baseClass
|
||||||
container = L.DomUtil.create('div', className, parent)
|
const container = L.DomUtil.create('div', className, parent)
|
||||||
U.Icon.makeIconElement(value, container)
|
U.Icon.makeIconElement(value, container)
|
||||||
container.title = title
|
container.title = title
|
||||||
L.DomEvent.on(
|
L.DomEvent.on(
|
||||||
|
@ -743,9 +738,9 @@ L.FormBuilder.FacetSearchChoices = L.FormBuilder.FacetSearchBase.extend({
|
||||||
this.container = L.DomUtil.create('fieldset', 'umap-facet', this.parentNode)
|
this.container = L.DomUtil.create('fieldset', 'umap-facet', this.parentNode)
|
||||||
this.container.appendChild(this.label)
|
this.container.appendChild(this.label)
|
||||||
this.ul = L.DomUtil.create('ul', '', this.container)
|
this.ul = L.DomUtil.create('ul', '', this.container)
|
||||||
this.type = this.options.criteria['type']
|
this.type = this.options.criteria.type
|
||||||
|
|
||||||
const choices = this.options.criteria['choices']
|
const choices = this.options.criteria.choices
|
||||||
choices.sort()
|
choices.sort()
|
||||||
choices.forEach((value) => this.buildLi(value))
|
choices.forEach((value) => this.buildLi(value))
|
||||||
},
|
},
|
||||||
|
@ -758,7 +753,7 @@ L.FormBuilder.FacetSearchChoices = L.FormBuilder.FacetSearchBase.extend({
|
||||||
|
|
||||||
input.type = this.type
|
input.type = this.type
|
||||||
input.name = `${this.type}_${this.name}`
|
input.name = `${this.type}_${this.name}`
|
||||||
input.checked = this.get()['choices'].includes(value)
|
input.checked = this.get().choices.includes(value)
|
||||||
input.dataset.value = value
|
input.dataset.value = value
|
||||||
|
|
||||||
L.DomEvent.on(input, 'change', (e) => this.sync())
|
L.DomEvent.on(input, 'change', (e) => this.sync())
|
||||||
|
@ -845,13 +840,13 @@ L.FormBuilder.MinMaxBase = L.FormBuilder.FacetSearchBase.extend({
|
||||||
isMinModified: function () {
|
isMinModified: function () {
|
||||||
const default_ = this.minInput.getAttribute('value')
|
const default_ = this.minInput.getAttribute('value')
|
||||||
const current = this.minInput.value
|
const current = this.minInput.value
|
||||||
return current != default_
|
return current !== default_
|
||||||
},
|
},
|
||||||
|
|
||||||
isMaxModified: function () {
|
isMaxModified: function () {
|
||||||
const default_ = this.maxInput.getAttribute('value')
|
const default_ = this.maxInput.getAttribute('value')
|
||||||
const current = this.maxInput.value
|
const current = this.maxInput.value
|
||||||
return current != default_
|
return current !== default_
|
||||||
},
|
},
|
||||||
|
|
||||||
toJS: function () {
|
toJS: function () {
|
||||||
|
@ -879,7 +874,7 @@ L.FormBuilder.FacetSearchDate = L.FormBuilder.MinMaxBase.extend({
|
||||||
|
|
||||||
prepareForHTML: function (value) {
|
prepareForHTML: function (value) {
|
||||||
// Value must be in local time
|
// Value must be in local time
|
||||||
if (isNaN(value)) return
|
if (Number.isNaN(value)) return
|
||||||
return this.toLocaleDateTime(value).toISOString().substr(0, 10)
|
return this.toLocaleDateTime(value).toISOString().substr(0, 10)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -891,7 +886,7 @@ L.FormBuilder.FacetSearchDateTime = L.FormBuilder.FacetSearchDate.extend({
|
||||||
|
|
||||||
prepareForHTML: function (value) {
|
prepareForHTML: function (value) {
|
||||||
// Value must be in local time
|
// Value must be in local time
|
||||||
if (isNaN(value)) return
|
if (Number.isNaN(value)) return
|
||||||
return this.toLocaleDateTime(value).toISOString().slice(0, -1)
|
return this.toLocaleDateTime(value).toISOString().slice(0, -1)
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
@ -1138,7 +1133,7 @@ U.FormBuilder = L.FormBuilder.extend({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// FormBuilder use this key for the input type itself
|
// FormBuilder use this key for the input type itself
|
||||||
delete schema.type
|
schema.type = undefined
|
||||||
this.defaultOptions[key] = schema
|
this.defaultOptions[key] = schema
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -12,7 +12,7 @@ U.Icon = L.DivIcon.extend({
|
||||||
options = L.Util.extend({}, default_options, options)
|
options = L.Util.extend({}, default_options, options)
|
||||||
L.Icon.prototype.initialize.call(this, options)
|
L.Icon.prototype.initialize.call(this, options)
|
||||||
this.feature = this.options.feature
|
this.feature = this.options.feature
|
||||||
if (this.feature && this.feature.isReadOnly()) {
|
if (this.feature?.isReadOnly()) {
|
||||||
this.options.className += ' readonly'
|
this.options.className += ' readonly'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -27,7 +27,7 @@ U.Icon = L.DivIcon.extend({
|
||||||
|
|
||||||
_getIconUrl: function (name) {
|
_getIconUrl: function (name) {
|
||||||
let url
|
let url
|
||||||
if (this.feature && this.feature._getIconUrl(name)) {
|
if (this.feature?._getIconUrl(name)) {
|
||||||
url = this.feature._getIconUrl(name)
|
url = this.feature._getIconUrl(name)
|
||||||
this._setRecent(url)
|
this._setRecent(url)
|
||||||
} else {
|
} else {
|
||||||
|
@ -70,8 +70,8 @@ U.Icon.Default = U.Icon.extend({
|
||||||
|
|
||||||
_setIconStyles: function (img, name) {
|
_setIconStyles: function (img, name) {
|
||||||
U.Icon.prototype._setIconStyles.call(this, img, name)
|
U.Icon.prototype._setIconStyles.call(this, img, name)
|
||||||
const color = this._getColor(),
|
const color = this._getColor()
|
||||||
opacity = this._getOpacity()
|
const opacity = this._getOpacity()
|
||||||
this.elements.container.style.backgroundColor = color
|
this.elements.container.style.backgroundColor = color
|
||||||
this.elements.arrow.style.borderTopColor = color
|
this.elements.arrow.style.borderTopColor = color
|
||||||
this.elements.container.style.opacity = opacity
|
this.elements.container.style.opacity = opacity
|
||||||
|
@ -185,10 +185,10 @@ U.Icon.Cluster = L.DivIcon.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
createIcon: function () {
|
createIcon: function () {
|
||||||
const container = L.DomUtil.create('div', 'leaflet-marker-icon marker-cluster'),
|
const container = L.DomUtil.create('div', 'leaflet-marker-icon marker-cluster')
|
||||||
div = L.DomUtil.create('div', '', container),
|
const div = L.DomUtil.create('div', '', container)
|
||||||
span = L.DomUtil.create('span', '', div),
|
const span = L.DomUtil.create('span', '', div)
|
||||||
backgroundColor = this.datalayer.getColor()
|
const backgroundColor = this.datalayer.getColor()
|
||||||
span.textContent = this.cluster.getChildCount()
|
span.textContent = this.cluster.getChildCount()
|
||||||
div.style.backgroundColor = backgroundColor
|
div.style.backgroundColor = backgroundColor
|
||||||
return container
|
return container
|
||||||
|
@ -197,7 +197,7 @@ U.Icon.Cluster = L.DivIcon.extend({
|
||||||
computeTextColor: function (el) {
|
computeTextColor: function (el) {
|
||||||
let color
|
let color
|
||||||
const backgroundColor = this.datalayer.getColor()
|
const backgroundColor = this.datalayer.getColor()
|
||||||
if (this.datalayer.options.cluster && this.datalayer.options.cluster.textColor) {
|
if (this.datalayer.options.cluster?.textColor) {
|
||||||
color = this.datalayer.options.cluster.textColor
|
color = this.datalayer.options.cluster.textColor
|
||||||
}
|
}
|
||||||
return color || L.DomUtil.TextColorFromBackgroundColor(el, backgroundColor)
|
return color || L.DomUtil.TextColorFromBackgroundColor(el, backgroundColor)
|
||||||
|
|
|
@ -99,16 +99,12 @@ U.Map = L.Map.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrocompat
|
// Retrocompat
|
||||||
if (
|
if (this.options.slideshow?.delay && this.options.slideshow.active === undefined) {
|
||||||
this.options.slideshow &&
|
|
||||||
this.options.slideshow.delay &&
|
|
||||||
this.options.slideshow.active === undefined
|
|
||||||
) {
|
|
||||||
this.options.slideshow.active = true
|
this.options.slideshow.active = true
|
||||||
}
|
}
|
||||||
if (this.options.advancedFilterKey) {
|
if (this.options.advancedFilterKey) {
|
||||||
this.options.facetKey = this.options.advancedFilterKey
|
this.options.facetKey = this.options.advancedFilterKey
|
||||||
delete this.options.advancedFilterKey
|
this.options.advancedFilterKey = undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global storage for retrieving datalayers and features
|
// Global storage for retrieving datalayers and features
|
||||||
|
@ -134,14 +130,14 @@ U.Map = L.Map.extend({
|
||||||
if (!this.options.onLoadPanel) {
|
if (!this.options.onLoadPanel) {
|
||||||
this.options.onLoadPanel = 'caption'
|
this.options.onLoadPanel = 'caption'
|
||||||
}
|
}
|
||||||
delete this.options.displayCaptionOnLoad
|
this.options.displayCaptionOnLoad = undefined
|
||||||
}
|
}
|
||||||
if (this.options.displayDataBrowserOnLoad) {
|
if (this.options.displayDataBrowserOnLoad) {
|
||||||
// Retrocompat
|
// Retrocompat
|
||||||
if (!this.options.onLoadPanel) {
|
if (!this.options.onLoadPanel) {
|
||||||
this.options.onLoadPanel = 'databrowser'
|
this.options.onLoadPanel = 'databrowser'
|
||||||
}
|
}
|
||||||
delete this.options.displayDataBrowserOnLoad
|
this.options.displayDataBrowserOnLoad = undefined
|
||||||
}
|
}
|
||||||
if (this.options.datalayersControl === 'expanded') {
|
if (this.options.datalayersControl === 'expanded') {
|
||||||
this.options.onLoadPanel = 'datalayers'
|
this.options.onLoadPanel = 'datalayers'
|
||||||
|
@ -211,8 +207,8 @@ U.Map = L.Map.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
initSyncEngine: async function () {
|
initSyncEngine: async function () {
|
||||||
if (this.options.websocketEnabled == false) return
|
if (this.options.websocketEnabled === false) return
|
||||||
if (this.options.syncEnabled != true) {
|
if (this.options.syncEnabled !== true) {
|
||||||
this.sync.stop()
|
this.sync.stop()
|
||||||
} else {
|
} else {
|
||||||
const ws_token_uri = this.urls.get('map_websocket_auth_token', {
|
const ws_token_uri = this.urls.get('map_websocket_auth_token', {
|
||||||
|
@ -414,9 +410,7 @@ U.Map = L.Map.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
renderControls: function () {
|
renderControls: function () {
|
||||||
const hasSlideshow = Boolean(
|
const hasSlideshow = Boolean(this.options.slideshow?.active)
|
||||||
this.options.slideshow && this.options.slideshow.active
|
|
||||||
)
|
|
||||||
const barEnabled = this.options.captionBar || hasSlideshow
|
const barEnabled = this.options.captionBar || hasSlideshow
|
||||||
document.body.classList.toggle('umap-caption-bar-enabled', barEnabled)
|
document.body.classList.toggle('umap-caption-bar-enabled', barEnabled)
|
||||||
document.body.classList.toggle('umap-slideshow-enabled', hasSlideshow)
|
document.body.classList.toggle('umap-slideshow-enabled', hasSlideshow)
|
||||||
|
@ -444,7 +438,9 @@ U.Map = L.Map.extend({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
let name, status, control
|
let name
|
||||||
|
let status
|
||||||
|
let control
|
||||||
for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
|
for (let i = 0; i < this.HIDDABLE_CONTROLS.length; i++) {
|
||||||
name = this.HIDDABLE_CONTROLS[i]
|
name = this.HIDDABLE_CONTROLS[i]
|
||||||
status = this.getOption(`${name}Control`)
|
status = this.getOption(`${name}Control`)
|
||||||
|
@ -629,11 +625,7 @@ U.Map = L.Map.extend({
|
||||||
this.options.tilelayer.attribution = props.attribution
|
this.options.tilelayer.attribution = props.attribution
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (
|
if (this.options.tilelayer?.url_template && this.options.tilelayer.attribution) {
|
||||||
this.options.tilelayer &&
|
|
||||||
this.options.tilelayer.url_template &&
|
|
||||||
this.options.tilelayer.attribution
|
|
||||||
) {
|
|
||||||
this.customTilelayer = this.createTileLayer(this.options.tilelayer)
|
this.customTilelayer = this.createTileLayer(this.options.tilelayer)
|
||||||
this.selectTileLayer(this.customTilelayer)
|
this.selectTileLayer(this.customTilelayer)
|
||||||
} else {
|
} else {
|
||||||
|
@ -656,13 +648,13 @@ U.Map = L.Map.extend({
|
||||||
}
|
}
|
||||||
this.selected_tilelayer = tilelayer
|
this.selected_tilelayer = tilelayer
|
||||||
if (
|
if (
|
||||||
!isNaN(this.selected_tilelayer.options.minZoom) &&
|
!Number.isNaN(this.selected_tilelayer.options.minZoom) &&
|
||||||
this.getZoom() < this.selected_tilelayer.options.minZoom
|
this.getZoom() < this.selected_tilelayer.options.minZoom
|
||||||
) {
|
) {
|
||||||
this.setZoom(this.selected_tilelayer.options.minZoom)
|
this.setZoom(this.selected_tilelayer.options.minZoom)
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
!isNaN(this.selected_tilelayer.options.maxZoom) &&
|
!Number.isNaN(this.selected_tilelayer.options.maxZoom) &&
|
||||||
this.getZoom() > this.selected_tilelayer.options.maxZoom
|
this.getZoom() > this.selected_tilelayer.options.maxZoom
|
||||||
) {
|
) {
|
||||||
this.setZoom(this.selected_tilelayer.options.maxZoom)
|
this.setZoom(this.selected_tilelayer.options.maxZoom)
|
||||||
|
@ -759,11 +751,16 @@ U.Map = L.Map.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
handleLimitBounds: function () {
|
handleLimitBounds: function () {
|
||||||
const south = Number.parseFloat(this.options.limitBounds.south),
|
const south = Number.parseFloat(this.options.limitBounds.south)
|
||||||
west = Number.parseFloat(this.options.limitBounds.west),
|
const west = Number.parseFloat(this.options.limitBounds.west)
|
||||||
north = Number.parseFloat(this.options.limitBounds.north),
|
const north = Number.parseFloat(this.options.limitBounds.north)
|
||||||
east = Number.parseFloat(this.options.limitBounds.east)
|
const east = Number.parseFloat(this.options.limitBounds.east)
|
||||||
if (!isNaN(south) && !isNaN(west) && !isNaN(north) && !isNaN(east)) {
|
if (
|
||||||
|
!Number.isNaN(south) &&
|
||||||
|
!Number.isNaN(west) &&
|
||||||
|
!Number.isNaN(north) &&
|
||||||
|
!Number.isNaN(east)
|
||||||
|
) {
|
||||||
const bounds = L.latLngBounds([
|
const bounds = L.latLngBounds([
|
||||||
[south, west],
|
[south, west],
|
||||||
[north, east],
|
[north, east],
|
||||||
|
@ -793,7 +790,7 @@ U.Map = L.Map.extend({
|
||||||
return L.Map.prototype.setMaxBounds.call(this, bounds)
|
return L.Map.prototype.setMaxBounds.call(this, bounds)
|
||||||
},
|
},
|
||||||
|
|
||||||
createDataLayer: function (options = {}, sync) {
|
createDataLayer: function (options, sync) {
|
||||||
options.name = options.name || `${L._('Layer')} ${this.datalayers_index.length + 1}`
|
options.name = options.name || `${L._('Layer')} ${this.datalayers_index.length + 1}`
|
||||||
const datalayer = new U.DataLayer(this, options, sync)
|
const datalayer = new U.DataLayer(this, options, sync)
|
||||||
|
|
||||||
|
@ -808,7 +805,7 @@ U.Map = L.Map.extend({
|
||||||
datalayer.edit()
|
datalayer.edit()
|
||||||
},
|
},
|
||||||
|
|
||||||
getDefaultOption: (option) => U.SCHEMA[option] && U.SCHEMA[option].default,
|
getDefaultOption: (option) => U.SCHEMA[option]?.default,
|
||||||
|
|
||||||
getOption: function (option, feature) {
|
getOption: function (option, feature) {
|
||||||
if (feature) {
|
if (feature) {
|
||||||
|
@ -883,7 +880,7 @@ U.Map = L.Map.extend({
|
||||||
|
|
||||||
importFromUrl: async function (uri) {
|
importFromUrl: async function (uri) {
|
||||||
const response = await this.request.get(uri)
|
const response = await this.request.get(uri)
|
||||||
if (response && response.ok) {
|
if (response?.ok) {
|
||||||
this.importRaw(await response.text())
|
this.importRaw(await response.text())
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -904,7 +901,7 @@ U.Map = L.Map.extend({
|
||||||
importedData.layers.forEach((geojson) => {
|
importedData.layers.forEach((geojson) => {
|
||||||
if (!geojson._umap_options && geojson._storage) {
|
if (!geojson._umap_options && geojson._storage) {
|
||||||
geojson._umap_options = geojson._storage
|
geojson._umap_options = geojson._storage
|
||||||
delete geojson._storage
|
geojson._storage = undefined
|
||||||
}
|
}
|
||||||
delete geojson._umap_options?.id // Never trust an id at this stage
|
delete geojson._umap_options?.id // Never trust an id at this stage
|
||||||
const dataLayer = this.createDataLayer(geojson._umap_options)
|
const dataLayer = this.createDataLayer(geojson._umap_options)
|
||||||
|
@ -1134,7 +1131,8 @@ U.Map = L.Map.extend({
|
||||||
// (edit and viewing)
|
// (edit and viewing)
|
||||||
// cf https://github.com/umap-project/umap/issues/585
|
// cf https://github.com/umap-project/umap/issues/585
|
||||||
defaultEditDataLayer: function () {
|
defaultEditDataLayer: function () {
|
||||||
let datalayer, fallback
|
let datalayer
|
||||||
|
let fallback
|
||||||
datalayer = this.lastUsedDataLayer
|
datalayer = this.lastUsedDataLayer
|
||||||
if (
|
if (
|
||||||
datalayer &&
|
datalayer &&
|
||||||
|
@ -1160,7 +1158,7 @@ U.Map = L.Map.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getDataLayerByUmapId: function (umap_id) {
|
getDataLayerByUmapId: function (umap_id) {
|
||||||
return this.findDataLayer((d) => d.umap_id == umap_id)
|
return this.findDataLayer((d) => d.umap_id === umap_id)
|
||||||
},
|
},
|
||||||
|
|
||||||
_editControls: function (container) {
|
_editControls: function (container) {
|
||||||
|
@ -1340,7 +1338,6 @@ U.Map = L.Map.extend({
|
||||||
'options.overlay.url_template',
|
'options.overlay.url_template',
|
||||||
{
|
{
|
||||||
handler: 'BlurInput',
|
handler: 'BlurInput',
|
||||||
helpText: `${L._('Supported scheme')}: http://{s}.domain.com/{z}/{x}/{y}.png`,
|
|
||||||
placeholder: 'url',
|
placeholder: 'url',
|
||||||
helpText: L._('Background overlay url'),
|
helpText: L._('Background overlay url'),
|
||||||
type: 'url',
|
type: 'url',
|
||||||
|
@ -1602,8 +1599,8 @@ U.Map = L.Map.extend({
|
||||||
'div',
|
'div',
|
||||||
'umap-caption-bar',
|
'umap-caption-bar',
|
||||||
this._controlContainer
|
this._controlContainer
|
||||||
),
|
)
|
||||||
name = L.DomUtil.create('h3', '', container)
|
const name = L.DomUtil.create('h3', '', container)
|
||||||
L.DomEvent.disableClickPropagation(container)
|
L.DomEvent.disableClickPropagation(container)
|
||||||
this.permissions.addOwnerLink('span', container)
|
this.permissions.addOwnerLink('span', container)
|
||||||
if (this.getOption('captionMenus')) {
|
if (this.getOption('captionMenus')) {
|
||||||
|
@ -1715,7 +1712,7 @@ U.Map = L.Map.extend({
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if (e && e.relatedTarget) {
|
if (e?.relatedTarget) {
|
||||||
if (e.relatedTarget.getContextMenuItems) {
|
if (e.relatedTarget.getContextMenuItems) {
|
||||||
items = items.concat(e.relatedTarget.getContextMenuItems(e))
|
items = items.concat(e.relatedTarget.getContextMenuItems(e))
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ U.Layer.Cluster = L.MarkerClusterGroup.extend({
|
||||||
},
|
},
|
||||||
iconCreateFunction: (cluster) => new U.Icon.Cluster(datalayer, cluster),
|
iconCreateFunction: (cluster) => new U.Icon.Cluster(datalayer, cluster),
|
||||||
}
|
}
|
||||||
if (this.datalayer.options.cluster && this.datalayer.options.cluster.radius) {
|
if (this.datalayer.options.cluster?.radius) {
|
||||||
options.maxClusterRadius = this.datalayer.options.cluster.radius
|
options.maxClusterRadius = this.datalayer.options.cluster.radius
|
||||||
}
|
}
|
||||||
L.MarkerClusterGroup.prototype.initialize.call(this, options)
|
L.MarkerClusterGroup.prototype.initialize.call(this, options)
|
||||||
|
@ -177,7 +177,7 @@ U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
const values = []
|
const values = []
|
||||||
this.datalayer.eachLayer((layer) => {
|
this.datalayer.eachLayer((layer) => {
|
||||||
const value = this._getValue(layer)
|
const value = this._getValue(layer)
|
||||||
if (!isNaN(value)) values.push(value)
|
if (!Number.isNaN(value)) values.push(value)
|
||||||
})
|
})
|
||||||
return values
|
return values
|
||||||
},
|
},
|
||||||
|
@ -190,9 +190,9 @@ U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
this.options.colors = []
|
this.options.colors = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
let mode = this.datalayer.options.choropleth.mode,
|
const mode = this.datalayer.options.choropleth.mode
|
||||||
classes = +this.datalayer.options.choropleth.classes || 5,
|
let classes = +this.datalayer.options.choropleth.classes || 5
|
||||||
breaks
|
let breaks
|
||||||
classes = Math.min(classes, values.length)
|
classes = Math.min(classes, values.length)
|
||||||
if (mode === 'manual') {
|
if (mode === 'manual') {
|
||||||
const manualBreaks = this.datalayer.options.choropleth.breaks
|
const manualBreaks = this.datalayer.options.choropleth.breaks
|
||||||
|
@ -200,7 +200,7 @@ U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
breaks = manualBreaks
|
breaks = manualBreaks
|
||||||
.split(',')
|
.split(',')
|
||||||
.map((b) => +b)
|
.map((b) => +b)
|
||||||
.filter((b) => !isNaN(b))
|
.filter((b) => !Number.isNaN(b))
|
||||||
}
|
}
|
||||||
} else if (mode === 'equidistant') {
|
} else if (mode === 'equidistant') {
|
||||||
breaks = ss.equalIntervalBreaks(values, classes)
|
breaks = ss.equalIntervalBreaks(values, classes)
|
||||||
|
@ -243,7 +243,7 @@ U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
addLayer: function (layer) {
|
addLayer: function (layer) {
|
||||||
// Do not add yet the layer to the map
|
// Do not add yet the layer to the map
|
||||||
// wait for datachanged event, so we want compute breaks once
|
// wait for datachanged event, so we want compute breaks once
|
||||||
var id = this.getLayerId(layer)
|
const id = this.getLayerId(layer)
|
||||||
this._layers[id] = layer
|
this._layers[id] = layer
|
||||||
return this
|
return this
|
||||||
},
|
},
|
||||||
|
@ -326,7 +326,9 @@ U.Layer.Choropleth = L.FeatureGroup.extend({
|
||||||
|
|
||||||
renderLegend: function (container) {
|
renderLegend: function (container) {
|
||||||
const parent = L.DomUtil.create('ul', '', container)
|
const parent = L.DomUtil.create('ul', '', container)
|
||||||
let li, color, label
|
let li
|
||||||
|
let color
|
||||||
|
let label
|
||||||
|
|
||||||
this.options.breaks.slice(0, -1).forEach((limit, index) => {
|
this.options.breaks.slice(0, -1).forEach((limit, index) => {
|
||||||
li = L.DomUtil.create('li', '', parent)
|
li = L.DomUtil.create('li', '', parent)
|
||||||
|
@ -358,12 +360,9 @@ U.Layer.Heat = L.HeatLayer.extend({
|
||||||
|
|
||||||
addLayer: function (layer) {
|
addLayer: function (layer) {
|
||||||
if (layer instanceof L.Marker) {
|
if (layer instanceof L.Marker) {
|
||||||
let latlng = layer.getLatLng(),
|
let latlng = layer.getLatLng()
|
||||||
alt
|
let alt
|
||||||
if (
|
if (this.datalayer.options.heat?.intensityProperty) {
|
||||||
this.datalayer.options.heat &&
|
|
||||||
this.datalayer.options.heat.intensityProperty
|
|
||||||
) {
|
|
||||||
alt = Number.parseFloat(
|
alt = Number.parseFloat(
|
||||||
layer.properties[this.datalayer.options.heat.intensityProperty || 0]
|
layer.properties[this.datalayer.options.heat.intensityProperty || 0]
|
||||||
)
|
)
|
||||||
|
@ -430,23 +429,23 @@ U.Layer.Heat = L.HeatLayer.extend({
|
||||||
if (!this._map) {
|
if (!this._map) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
var data = [],
|
const data = []
|
||||||
r = this._heat._r,
|
const r = this._heat._r
|
||||||
size = this._map.getSize(),
|
const size = this._map.getSize()
|
||||||
bounds = new L.Bounds(L.point([-r, -r]), size.add([r, r])),
|
const bounds = new L.Bounds(L.point([-r, -r]), size.add([r, r]))
|
||||||
cellSize = r / 2,
|
const cellSize = r / 2
|
||||||
grid = [],
|
const grid = []
|
||||||
panePos = this._map._getMapPanePos(),
|
const panePos = this._map._getMapPanePos()
|
||||||
offsetX = panePos.x % cellSize,
|
const offsetX = panePos.x % cellSize
|
||||||
offsetY = panePos.y % cellSize,
|
const offsetY = panePos.y % cellSize
|
||||||
i,
|
let i
|
||||||
len,
|
let len
|
||||||
p,
|
let p
|
||||||
cell,
|
let cell
|
||||||
x,
|
let x
|
||||||
y,
|
let y
|
||||||
j,
|
let j
|
||||||
len2
|
let len2
|
||||||
|
|
||||||
this._max = 1
|
this._max = 1
|
||||||
|
|
||||||
|
@ -455,7 +454,7 @@ U.Layer.Heat = L.HeatLayer.extend({
|
||||||
x = Math.floor((p.x - offsetX) / cellSize) + 2
|
x = Math.floor((p.x - offsetX) / cellSize) + 2
|
||||||
y = Math.floor((p.y - offsetY) / cellSize) + 2
|
y = Math.floor((p.y - offsetY) / cellSize) + 2
|
||||||
|
|
||||||
var alt =
|
const alt =
|
||||||
this._latlngs[i].alt !== undefined
|
this._latlngs[i].alt !== undefined
|
||||||
? this._latlngs[i].alt
|
? this._latlngs[i].alt
|
||||||
: this._latlngs[i][2] !== undefined
|
: this._latlngs[i][2] !== undefined
|
||||||
|
@ -567,13 +566,13 @@ U.DataLayer = L.Evented.extend({
|
||||||
this.options.remoteData = {}
|
this.options.remoteData = {}
|
||||||
}
|
}
|
||||||
// Retrocompat
|
// Retrocompat
|
||||||
if (this.options.remoteData && this.options.remoteData.from) {
|
if (this.options.remoteData?.from) {
|
||||||
this.options.fromZoom = this.options.remoteData.from
|
this.options.fromZoom = this.options.remoteData.from
|
||||||
delete this.options.remoteData.from
|
this.options.remoteData.from = undefined
|
||||||
}
|
}
|
||||||
if (this.options.remoteData && this.options.remoteData.to) {
|
if (this.options.remoteData?.to) {
|
||||||
this.options.toZoom = this.options.remoteData.to
|
this.options.toZoom = this.options.remoteData.to
|
||||||
delete this.options.remoteData.to
|
this.options.remoteData.to = undefined
|
||||||
}
|
}
|
||||||
this.backupOptions()
|
this.backupOptions()
|
||||||
this.connectToMap()
|
this.connectToMap()
|
||||||
|
@ -772,14 +771,14 @@ U.DataLayer = L.Evented.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
showAtZoom: function () {
|
showAtZoom: function () {
|
||||||
const from = Number.parseInt(this.options.fromZoom, 10),
|
const from = Number.parseInt(this.options.fromZoom, 10)
|
||||||
to = Number.parseInt(this.options.toZoom, 10),
|
const to = Number.parseInt(this.options.toZoom, 10)
|
||||||
zoom = this.map.getZoom()
|
const zoom = this.map.getZoom()
|
||||||
return !((!isNaN(from) && zoom < from) || (!isNaN(to) && zoom > to))
|
return !((!Number.isNaN(from) && zoom < from) || (!Number.isNaN(to) && zoom > to))
|
||||||
},
|
},
|
||||||
|
|
||||||
hasDynamicData: function () {
|
hasDynamicData: function () {
|
||||||
return !!(this.options.remoteData && this.options.remoteData.dynamic)
|
return !!this.options.remoteData?.dynamic
|
||||||
},
|
},
|
||||||
|
|
||||||
fetchRemoteData: async function (force) {
|
fetchRemoteData: async function (force) {
|
||||||
|
@ -791,7 +790,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
url = this.map.proxyUrl(url, this.options.remoteData.ttl)
|
url = this.map.proxyUrl(url, this.options.remoteData.ttl)
|
||||||
}
|
}
|
||||||
const response = await this.map.request.get(url)
|
const response = await this.map.request.get(url)
|
||||||
if (response && response.ok) {
|
if (response?.ok) {
|
||||||
this.clear()
|
this.clear()
|
||||||
this.rawToGeoJSON(
|
this.rawToGeoJSON(
|
||||||
await response.text(),
|
await response.text(),
|
||||||
|
@ -835,7 +834,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
setOptions: function (options) {
|
setOptions: function (options) {
|
||||||
delete options.geojson
|
options.geojson = undefined
|
||||||
this.options = U.Utils.CopyJSON(U.DataLayer.prototype.options) // Start from fresh.
|
this.options = U.Utils.CopyJSON(U.DataLayer.prototype.options) // Start from fresh.
|
||||||
this.updateOptions(options)
|
this.updateOptions(options)
|
||||||
},
|
},
|
||||||
|
@ -869,11 +868,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
isRemoteLayer: function () {
|
isRemoteLayer: function () {
|
||||||
return Boolean(
|
return Boolean(this.options.remoteData?.url && this.options.remoteData.format)
|
||||||
this.options.remoteData &&
|
|
||||||
this.options.remoteData.url &&
|
|
||||||
this.options.remoteData.format
|
|
||||||
)
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isClustered: function () {
|
isClustered: function () {
|
||||||
|
@ -960,7 +955,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
// csv2geojson fallback to null geometries when it cannot determine
|
// csv2geojson fallback to null geometries when it cannot determine
|
||||||
// lat or lon columns. This is valid geojson, but unwanted from a user
|
// lat or lon columns. This is valid geojson, but unwanted from a user
|
||||||
// point of view.
|
// point of view.
|
||||||
if (result && result.features.length) {
|
if (result?.features.length) {
|
||||||
if (result.features[0].geometry === null) {
|
if (result.features[0].geometry === null) {
|
||||||
err = {
|
err = {
|
||||||
type: 'Error',
|
type: 'Error',
|
||||||
|
@ -981,7 +976,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
U.Alert.error(message, 10000)
|
U.Alert.error(message, 10000)
|
||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
if (result && result.features.length) {
|
if (result?.features.length) {
|
||||||
callback(result)
|
callback(result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1016,7 +1011,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
// GeoJSON features.
|
// GeoJSON features.
|
||||||
geojsonToFeatures: function (geojson) {
|
geojsonToFeatures: function (geojson) {
|
||||||
if (!geojson) return
|
if (!geojson) return
|
||||||
const features = geojson instanceof Array ? geojson : geojson.features
|
const features = Array.isArray(geojson) ? geojson : geojson.features
|
||||||
let i
|
let i
|
||||||
let len
|
let len
|
||||||
|
|
||||||
|
@ -1062,7 +1057,8 @@ U.DataLayer = L.Evented.extend({
|
||||||
} = {}) {
|
} = {}) {
|
||||||
if (!geometry) return // null geometry is valid geojson.
|
if (!geometry) return // null geometry is valid geojson.
|
||||||
const coords = geometry.coordinates
|
const coords = geometry.coordinates
|
||||||
let latlng, latlngs
|
let latlng
|
||||||
|
let latlngs
|
||||||
|
|
||||||
// Create a default geojson if none is provided
|
// Create a default geojson if none is provided
|
||||||
if (geojson === undefined) geojson = { type: 'Feature', geometry: geometry }
|
if (geojson === undefined) geojson = { type: 'Feature', geometry: geometry }
|
||||||
|
@ -1161,7 +1157,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
importFromUrl: async function (uri, type) {
|
importFromUrl: async function (uri, type) {
|
||||||
uri = this.map.localizeUrl(uri)
|
uri = this.map.localizeUrl(uri)
|
||||||
const response = await this.map.request.get(uri)
|
const response = await this.map.request.get(uri)
|
||||||
if (response && response.ok) {
|
if (response?.ok) {
|
||||||
this.importRaw(await response.text(), type)
|
this.importRaw(await response.text(), type)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1206,9 +1202,9 @@ U.DataLayer = L.Evented.extend({
|
||||||
clone: function () {
|
clone: function () {
|
||||||
const options = U.Utils.CopyJSON(this.options)
|
const options = U.Utils.CopyJSON(this.options)
|
||||||
options.name = L._('Clone of {name}', { name: this.options.name })
|
options.name = L._('Clone of {name}', { name: this.options.name })
|
||||||
delete options.id
|
options.id = undefined
|
||||||
const geojson = U.Utils.CopyJSON(this._geojson),
|
const geojson = U.Utils.CopyJSON(this._geojson)
|
||||||
datalayer = this.map.createDataLayer(options)
|
const datalayer = this.map.createDataLayer(options)
|
||||||
datalayer.fromGeoJSON(geojson)
|
datalayer.fromGeoJSON(geojson)
|
||||||
return datalayer
|
return datalayer
|
||||||
},
|
},
|
||||||
|
@ -1226,8 +1222,8 @@ U.DataLayer = L.Evented.extend({
|
||||||
this.map.off('zoomend', this.onZoomEnd, this)
|
this.map.off('zoomend', this.onZoomEnd, this)
|
||||||
this.off()
|
this.off()
|
||||||
this.clear()
|
this.clear()
|
||||||
delete this._loaded
|
this._loaded = undefined
|
||||||
delete this._dataloaded
|
this._dataloaded = undefined
|
||||||
},
|
},
|
||||||
|
|
||||||
reset: function () {
|
reset: function () {
|
||||||
|
@ -1257,8 +1253,8 @@ U.DataLayer = L.Evented.extend({
|
||||||
if (!this.map.editEnabled || !this.isLoaded()) {
|
if (!this.map.editEnabled || !this.isLoaded()) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const container = L.DomUtil.create('div', 'umap-layer-properties-container'),
|
const container = L.DomUtil.create('div', 'umap-layer-properties-container')
|
||||||
metadataFields = [
|
const metadataFields = [
|
||||||
'options.name',
|
'options.name',
|
||||||
'options.description',
|
'options.description',
|
||||||
['options.type', { handler: 'LayerTypeChooser', label: L._('Type of layer') }],
|
['options.type', { handler: 'LayerTypeChooser', label: L._('Type of layer') }],
|
||||||
|
@ -1469,17 +1465,17 @@ U.DataLayer = L.Evented.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
getOption: function (option, feature) {
|
getOption: function (option, feature) {
|
||||||
if (this.layer && this.layer.getOption) {
|
if (this.layer?.getOption) {
|
||||||
const value = this.layer.getOption(option, feature)
|
const value = this.layer.getOption(option, feature)
|
||||||
if (typeof value !== 'undefined') return value
|
if (typeof value !== 'undefined') return value
|
||||||
}
|
}
|
||||||
if (typeof this.getOwnOption(option) !== 'undefined') {
|
if (typeof this.getOwnOption(option) !== 'undefined') {
|
||||||
return this.getOwnOption(option)
|
return this.getOwnOption(option)
|
||||||
} else if (this.layer && this.layer.defaults && this.layer.defaults[option]) {
|
|
||||||
return this.layer.defaults[option]
|
|
||||||
} else {
|
|
||||||
return this.map.getOption(option, feature)
|
|
||||||
}
|
}
|
||||||
|
if (this.layer?.defaults?.[option]) {
|
||||||
|
return this.layer.defaults[option]
|
||||||
|
}
|
||||||
|
return this.map.getOption(option, feature)
|
||||||
},
|
},
|
||||||
|
|
||||||
buildVersionsFieldset: async function (container) {
|
buildVersionsFieldset: async function (container) {
|
||||||
|
@ -1561,7 +1557,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
|
|
||||||
// Is this layer type browsable in theorie
|
// Is this layer type browsable in theorie
|
||||||
isBrowsable: function () {
|
isBrowsable: function () {
|
||||||
return this.layer && this.layer.browsable
|
return this.layer?.browsable
|
||||||
},
|
},
|
||||||
|
|
||||||
// Is this layer browsable in theorie
|
// Is this layer browsable in theorie
|
||||||
|
@ -1705,7 +1701,7 @@ U.DataLayer = L.Evented.extend({
|
||||||
if (data.geojson) {
|
if (data.geojson) {
|
||||||
this.clear()
|
this.clear()
|
||||||
this.fromGeoJSON(data.geojson)
|
this.fromGeoJSON(data.geojson)
|
||||||
delete data.geojson
|
data.geojson = undefined
|
||||||
}
|
}
|
||||||
this._reference_version = response.headers.get('X-Datalayer-Version')
|
this._reference_version = response.headers.get('X-Datalayer-Version')
|
||||||
this.sync.update('_reference_version', this._reference_version)
|
this.sync.update('_reference_version', this._reference_version)
|
||||||
|
@ -1748,9 +1744,9 @@ U.DataLayer = L.Evented.extend({
|
||||||
// By default, it will we use the "name" property, which is also the one used as label in the features list.
|
// By default, it will we use the "name" property, which is also the one used as label in the features list.
|
||||||
// When map owner has configured another label or sort key, we try to be smart and search in the same keys.
|
// When map owner has configured another label or sort key, we try to be smart and search in the same keys.
|
||||||
if (this.map.options.filterKey) return this.map.options.filterKey
|
if (this.map.options.filterKey) return this.map.options.filterKey
|
||||||
else if (this.options.labelKey) return this.options.labelKey
|
if (this.options.labelKey) return this.options.labelKey
|
||||||
else if (this.map.options.sortKey) return this.map.options.sortKey
|
if (this.map.options.sortKey) return this.map.options.sortKey
|
||||||
else return 'name'
|
return 'name'
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ U.MapPermissions = L.Class.extend({
|
||||||
return (
|
return (
|
||||||
this.map.options.user &&
|
this.map.options.user &&
|
||||||
this.map.options.permissions.owner &&
|
this.map.options.permissions.owner &&
|
||||||
this.map.options.user.id == this.map.options.permissions.owner.id
|
this.map.options.user.id === this.map.options.permissions.owner.id
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -151,7 +151,7 @@ U.MapPermissions = L.Class.extend({
|
||||||
if (this.isOwner() || this.isAnonymousMap())
|
if (this.isOwner() || this.isAnonymousMap())
|
||||||
formData.append('edit_status', this.options.edit_status)
|
formData.append('edit_status', this.options.edit_status)
|
||||||
if (this.isOwner()) {
|
if (this.isOwner()) {
|
||||||
formData.append('owner', this.options.owner && this.options.owner.id)
|
formData.append('owner', this.options.owner?.id)
|
||||||
formData.append('share_status', this.options.share_status)
|
formData.append('share_status', this.options.share_status)
|
||||||
}
|
}
|
||||||
const [data, response, error] = await this.map.server.post(
|
const [data, response, error] = await this.map.server.post(
|
||||||
|
@ -180,7 +180,7 @@ U.MapPermissions = L.Class.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
addOwnerLink: function (element, container) {
|
addOwnerLink: function (element, container) {
|
||||||
if (this.options.owner && this.options.owner.name && this.options.owner.url) {
|
if (this.options.owner?.name && this.options.owner.url) {
|
||||||
const ownerContainer = L.DomUtil.add(
|
const ownerContainer = L.DomUtil.add(
|
||||||
element,
|
element,
|
||||||
'umap-map-owner',
|
'umap-map-owner',
|
||||||
|
|
|
@ -14,8 +14,8 @@ U.Popup = L.Popup.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
format: function () {
|
format: function () {
|
||||||
const mode = this.feature.getOption('popupTemplate') || 'Default',
|
const mode = this.feature.getOption('popupTemplate') || 'Default'
|
||||||
klass = U.PopupTemplate[mode] || U.PopupTemplate.Default
|
const klass = U.PopupTemplate[mode] || U.PopupTemplate.Default
|
||||||
this.content = new klass(this.feature, this.container)
|
this.content = new klass(this.feature, this.container)
|
||||||
this.content.render()
|
this.content.render()
|
||||||
const els = this.container.querySelectorAll('img,iframe')
|
const els = this.container.querySelectorAll('img,iframe')
|
||||||
|
@ -125,12 +125,12 @@ U.PopupTemplate.Default = L.Class.extend({
|
||||||
|
|
||||||
renderFooter: function () {
|
renderFooter: function () {
|
||||||
if (this.feature.hasPopupFooter()) {
|
if (this.feature.hasPopupFooter()) {
|
||||||
const footer = L.DomUtil.create('ul', 'umap-popup-footer', this.container),
|
const footer = L.DomUtil.create('ul', 'umap-popup-footer', this.container)
|
||||||
previousLi = L.DomUtil.create('li', 'previous', footer),
|
const previousLi = L.DomUtil.create('li', 'previous', footer)
|
||||||
zoomLi = L.DomUtil.create('li', 'zoom', footer),
|
const zoomLi = L.DomUtil.create('li', 'zoom', footer)
|
||||||
nextLi = L.DomUtil.create('li', 'next', footer),
|
const nextLi = L.DomUtil.create('li', 'next', footer)
|
||||||
next = this.feature.getNext(),
|
const next = this.feature.getNext()
|
||||||
prev = this.feature.getPrevious()
|
const prev = this.feature.getPrevious()
|
||||||
// Fixme: remove me when this is merged and released
|
// Fixme: remove me when this is merged and released
|
||||||
// https://github.com/Leaflet/Leaflet/pull/9052
|
// https://github.com/Leaflet/Leaflet/pull/9052
|
||||||
L.DomEvent.disableClickPropagation(footer)
|
L.DomEvent.disableClickPropagation(footer)
|
||||||
|
@ -240,8 +240,8 @@ U.PopupTemplate.GeoRSSLink = U.PopupTemplate.Default.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
renderBody: function () {
|
renderBody: function () {
|
||||||
const title = this.renderTitle(this),
|
const title = this.renderTitle(this)
|
||||||
a = L.DomUtil.add('a')
|
const a = L.DomUtil.add('a')
|
||||||
a.href = this.feature.properties.link
|
a.href = this.feature.properties.link
|
||||||
a.target = '_blank'
|
a.target = '_blank'
|
||||||
a.appendChild(title)
|
a.appendChild(title)
|
||||||
|
@ -323,7 +323,7 @@ U.PopupTemplate.OSM = U.PopupTemplate.Default.extend({
|
||||||
L.DomUtil.element('a', { href: `mailto:${email}`, textContent: email })
|
L.DomUtil.element('a', { href: `mailto:${email}`, textContent: email })
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
const id = props['@id'] || props['id']
|
const id = props['@id'] || props.id
|
||||||
if (id) {
|
if (id) {
|
||||||
L.DomUtil.add(
|
L.DomUtil.add(
|
||||||
'div',
|
'div',
|
||||||
|
|
|
@ -19,11 +19,11 @@ U.Share = L.Class.extend({
|
||||||
formatter: (map) => {
|
formatter: (map) => {
|
||||||
const table = []
|
const table = []
|
||||||
map.eachFeature((feature) => {
|
map.eachFeature((feature) => {
|
||||||
const row = feature.toGeoJSON()['properties'],
|
const row = feature.toGeoJSON().properties
|
||||||
center = feature.getCenter()
|
const center = feature.getCenter()
|
||||||
delete row['_umap_options']
|
row._umap_options = undefined
|
||||||
row['Latitude'] = center.lat
|
row.Latitude = center.lat
|
||||||
row['Longitude'] = center.lng
|
row.Longitude = center.lng
|
||||||
table.push(row)
|
table.push(row)
|
||||||
})
|
})
|
||||||
return csv2geojson.dsv.csvFormat(table)
|
return csv2geojson.dsv.csvFormat(table)
|
||||||
|
@ -224,7 +224,7 @@ U.IframeExporter = L.Evented.extend({
|
||||||
if (this.options.viewCurrentFeature && this.map.currentFeature) {
|
if (this.options.viewCurrentFeature && this.map.currentFeature) {
|
||||||
this.queryString.feature = this.map.currentFeature.getSlug()
|
this.queryString.feature = this.map.currentFeature.getSlug()
|
||||||
} else {
|
} else {
|
||||||
delete this.queryString.feature
|
this.queryString.feature = undefined
|
||||||
}
|
}
|
||||||
if (this.options.keepCurrentDatalayers) {
|
if (this.options.keepCurrentDatalayers) {
|
||||||
this.map.eachDataLayer((datalayer) => {
|
this.map.eachDataLayer((datalayer) => {
|
||||||
|
@ -234,7 +234,7 @@ U.IframeExporter = L.Evented.extend({
|
||||||
})
|
})
|
||||||
this.queryString.datalayers = datalayers.join(',')
|
this.queryString.datalayers = datalayers.join(',')
|
||||||
} else {
|
} else {
|
||||||
delete this.queryString.datalayers
|
this.queryString.datalayers = undefined
|
||||||
}
|
}
|
||||||
const currentView = this.options.currentView ? window.location.hash : ''
|
const currentView = this.options.currentView ? window.location.hash : ''
|
||||||
const queryString = L.extend({}, this.queryString, options)
|
const queryString = L.extend({}, this.queryString, options)
|
||||||
|
|
|
@ -69,8 +69,8 @@ U.Slideshow = L.Class.extend({
|
||||||
timeSpinner: function () {
|
timeSpinner: function () {
|
||||||
const time = Number.parseInt(this.options.delay, 10)
|
const time = Number.parseInt(this.options.delay, 10)
|
||||||
if (!time) return
|
if (!time) return
|
||||||
const css = `rotation ${time / 1000}s infinite linear`,
|
const css = `rotation ${time / 1000}s infinite linear`
|
||||||
spinners = document.querySelectorAll('.umap-slideshow-toolbox .play .spinner')
|
const spinners = document.querySelectorAll('.umap-slideshow-toolbox .play .spinner')
|
||||||
for (let i = 0; i < spinners.length; i++) {
|
for (let i = 0; i < spinners.length; i++) {
|
||||||
spinners[i].style.animation = css
|
spinners[i].style.animation = css
|
||||||
spinners[i].style['-webkit-animation'] = css
|
spinners[i].style['-webkit-animation'] = css
|
||||||
|
@ -138,11 +138,11 @@ U.Slideshow = L.Class.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
renderToolbox: function (container) {
|
renderToolbox: function (container) {
|
||||||
const box = L.DomUtil.create('ul', 'umap-slideshow-toolbox'),
|
const box = L.DomUtil.create('ul', 'umap-slideshow-toolbox')
|
||||||
play = L.DomUtil.create('li', 'play', box),
|
const play = L.DomUtil.create('li', 'play', box)
|
||||||
stop = L.DomUtil.create('li', 'stop', box),
|
const stop = L.DomUtil.create('li', 'stop', box)
|
||||||
prev = L.DomUtil.create('li', 'prev', box),
|
const prev = L.DomUtil.create('li', 'prev', box)
|
||||||
next = L.DomUtil.create('li', 'next', box)
|
const next = L.DomUtil.create('li', 'next', box)
|
||||||
L.DomUtil.create('div', 'spinner', play)
|
L.DomUtil.create('div', 'spinner', play)
|
||||||
play.title = L._('Start slideshow')
|
play.title = L._('Start slideshow')
|
||||||
stop.title = L._('Stop slideshow')
|
stop.title = L._('Stop slideshow')
|
||||||
|
|
|
@ -15,10 +15,10 @@ U.TableEditor = L.Class.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
renderHeader: function (property) {
|
renderHeader: function (property) {
|
||||||
const container = L.DomUtil.create('div', 'tcell', this.header),
|
const container = L.DomUtil.create('div', 'tcell', this.header)
|
||||||
title = L.DomUtil.add('span', '', container, property),
|
const title = L.DomUtil.add('span', '', container, property)
|
||||||
del = L.DomUtil.create('i', 'umap-delete', container),
|
const del = L.DomUtil.create('i', 'umap-delete', container)
|
||||||
rename = L.DomUtil.create('i', 'umap-edit', container)
|
const rename = L.DomUtil.create('i', 'umap-edit', container)
|
||||||
del.title = L._('Delete this property on all the features')
|
del.title = L._('Delete this property on all the features')
|
||||||
rename.title = L._('Rename this property on all the features')
|
rename.title = L._('Rename this property on all the features')
|
||||||
const doDelete = function () {
|
const doDelete = function () {
|
||||||
|
|
Loading…
Reference in a new issue