mirror of
https://github.com/umap-project/umap.git
synced 2025-04-28 19:42:36 +02:00
fix: fix preview color for polygons
Use usually set the `color` property, but we want to use the fillColor if it sets.
This commit is contained in:
parent
00483882a1
commit
e3f59850a7
3 changed files with 14 additions and 2 deletions
|
@ -37,7 +37,7 @@ export default class Browser {
|
|||
? U.Icon.prototype.formatUrl(feature._getIconUrl(), feature)
|
||||
: null
|
||||
title.textContent = feature.getDisplayName() || '—'
|
||||
const bgcolor = feature.getDynamicOption(feature.staticOptions.mainColor)
|
||||
const bgcolor = feature.getPreviewColor()
|
||||
colorBox.style.backgroundColor = bgcolor
|
||||
if (symbol && symbol !== U.SCHEMA.iconUrl.default) {
|
||||
const icon = U.Icon.makeIconElement(symbol, colorBox)
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
U.FeatureMixin = {
|
||||
staticOptions: { mainColor: 'color' },
|
||||
|
||||
getPreviewColor: function () {
|
||||
return this.getDynamicOption(this.staticOptions.mainColor)
|
||||
},
|
||||
|
||||
getSyncMetadata: function () {
|
||||
return {
|
||||
subject: 'feature',
|
||||
|
@ -1203,6 +1207,14 @@ U.Polygon = L.Polygon.extend({
|
|||
return options
|
||||
},
|
||||
|
||||
getPreviewColor: function () {
|
||||
// If user set a fillColor, use it, otherwise default to color
|
||||
// which is usually the only one set
|
||||
const color = this.getDynamicOption(this.staticOptions.mainColor)
|
||||
if (color && color !== U.SCHEMA.color.default) return color
|
||||
return this.getDynamicOption('color')
|
||||
},
|
||||
|
||||
getInteractionOptions: () => {
|
||||
const options = U.FeatureMixin.getInteractionOptions()
|
||||
options.push('properties._umap_options.interactive')
|
||||
|
|
|
@ -265,7 +265,7 @@ U.PopupTemplate.OSM = U.PopupTemplate.Default.extend({
|
|||
const props = this.feature.properties
|
||||
const container = L.DomUtil.add('div')
|
||||
const title = L.DomUtil.add('h3', 'popup-title', container)
|
||||
const color = this.feature.getDynamicOption('color')
|
||||
const color = this.feature.getPreviewColor()
|
||||
title.style.backgroundColor = color
|
||||
const iconUrl = this.feature.getDynamicOption('iconUrl')
|
||||
const icon = U.Icon.makeIconElement(iconUrl, title)
|
||||
|
|
Loading…
Reference in a new issue