Merge pull request #1251 from umap-project/explicit-default
Explicitely use map default when dynamic var is unset
This commit is contained in:
commit
b70e20cc89
3 changed files with 15 additions and 9 deletions
|
@ -253,6 +253,10 @@ L.Util.buildQueryString = (params) => {
|
|||
|
||||
L.Util.getBaseUrl = () => `//${window.location.host}${window.location.pathname}`
|
||||
|
||||
L.Util.hasVar = (value) => {
|
||||
return typeof value === 'string' && value.indexOf('{') != -1
|
||||
}
|
||||
|
||||
L.DomUtil.add = (tagName, className, container, content) => {
|
||||
const el = L.DomUtil.create(tagName, className, container)
|
||||
if (content) {
|
||||
|
@ -548,7 +552,9 @@ L.U.Help = L.Class.extend({
|
|||
'A comma separated list of numbers that defines the stroke dash pattern. Ex.: "5, 10, 15".'
|
||||
),
|
||||
zoomTo: L._('Zoom level for automatic zooms'),
|
||||
labelKey: L._('The name of the property to use as feature label (eg.: "nom"). You can also use properties inside brackets to use more than one or mix with static content (eg.: "{name} in {place}")'),
|
||||
labelKey: L._(
|
||||
'The name of the property to use as feature label (eg.: "nom"). You can also use properties inside brackets to use more than one or mix with static content (eg.: "{name} in {place}")'
|
||||
),
|
||||
stroke: L._('Whether to display or not polygons paths.'),
|
||||
fill: L._('Whether to fill polygons with color.'),
|
||||
fillColor: L._('Optional. Same as color if not set.'),
|
||||
|
@ -557,7 +563,9 @@ L.U.Help = L.Class.extend({
|
|||
permanentCredit: L._(
|
||||
'Will be permanently visible in the bottom left corner of the map'
|
||||
),
|
||||
sortKey: L._('Comma separated list of properties to use for sorting features. To reverse the sort, put a minus sign (-) before. Eg. mykey,-otherkey.'),
|
||||
sortKey: L._(
|
||||
'Comma separated list of properties to use for sorting features. To reverse the sort, put a minus sign (-) before. Eg. mykey,-otherkey.'
|
||||
),
|
||||
slugKey: L._('The name of the property to use as feature unique identifier.'),
|
||||
filterKey: L._('Comma separated list of properties to use when filtering features'),
|
||||
advancedFilterKey: L._(
|
||||
|
|
|
@ -185,7 +185,7 @@ L.U.FeatureMixin = {
|
|||
if (fallback === undefined) fallback = this.datalayer.options.name
|
||||
const key = this.getOption('labelKey') || 'name'
|
||||
// Variables mode.
|
||||
if (key.indexOf('{') != -1)
|
||||
if (L.Util.hasVar(key))
|
||||
return L.Util.greedyTemplate(key, this.extendedProperties())
|
||||
// Simple mode.
|
||||
return this.properties[key] || this.properties.title || fallback
|
||||
|
@ -277,11 +277,9 @@ L.U.FeatureMixin = {
|
|||
getDynamicOption: function (option, fallback) {
|
||||
let value = this.getOption(option, fallback)
|
||||
// There is a variable inside.
|
||||
if (typeof value === 'string' && value.indexOf('{') != -1) {
|
||||
value = L.Util.greedyTemplate(value, this.properties)
|
||||
// We've not been able to replace the variable, let's reset
|
||||
// so we can set a decent default at next step.
|
||||
if (value.indexOf('{') != -1) value = undefined
|
||||
if (L.Util.hasVar(value)) {
|
||||
value = L.Util.greedyTemplate(value, this.properties, true)
|
||||
if (L.Util.hasVar(value)) value = this.map.getDefaultOption(option)
|
||||
}
|
||||
return value
|
||||
},
|
||||
|
|
|
@ -542,7 +542,7 @@ L.FormBuilder.IconUrl = L.FormBuilder.BlurInput.extend({
|
|||
},
|
||||
|
||||
udpatePreview: function () {
|
||||
if (this.value() && this.value().indexOf('{') === -1) {
|
||||
if (L.Util.hasVar(this.value())) {
|
||||
// Do not try to render URL with variables
|
||||
if (this.isUrl()) {
|
||||
const img = L.DomUtil.create(
|
||||
|
|
Loading…
Reference in a new issue