forked from github/dataease
fix: 符号地图数据包涵经纬度为空的记录label无法展示
This commit is contained in:
parent
455f480ae7
commit
40a7f59fe3
@ -352,24 +352,23 @@ export default {
|
|||||||
const defaultTemplate = "经度:${longitude},纬度:${latitude}"
|
const defaultTemplate = "经度:${longitude},纬度:${latitude}"
|
||||||
const templateWithField = getDefaultTemplate(chart, 'labelAxis', false, false)
|
const templateWithField = getDefaultTemplate(chart, 'labelAxis', false, false)
|
||||||
const labelTemplate = customAttr.label.labelTemplate || templateWithField || defaultTemplate
|
const labelTemplate = customAttr.label.labelTemplate || templateWithField || defaultTemplate
|
||||||
|
const data = originData.filter(item => item.longitude && item.latitude)
|
||||||
|
data.forEach(item => {
|
||||||
|
const properties = item.properties || {}
|
||||||
|
properties.longitude = item.longitude
|
||||||
|
properties.latitude = item.latitude
|
||||||
|
|
||||||
originData.forEach(item => {
|
try {
|
||||||
const properties = item.properties || {}
|
item.labelResult = this.fillStrTemplate(labelTemplate, properties)
|
||||||
properties.longitude = item.longitude
|
}catch (error) {
|
||||||
properties.latitude = item.latitude
|
|
||||||
|
|
||||||
|
}
|
||||||
try {
|
item.labelResult = item.labelResult || this.fillStrTemplate(defaultTemplate, properties)
|
||||||
item.labelResult = this.fillStrTemplate(labelTemplate, properties)
|
item.labelResult = item.labelResult.replaceAll('\n', ' ')
|
||||||
}catch (error) {
|
|
||||||
|
|
||||||
}
|
|
||||||
item.labelResult = item.labelResult || this.fillStrTemplate(defaultTemplate, properties)
|
|
||||||
item.labelResult = item.labelResult.replaceAll('\n', ' ')
|
|
||||||
})
|
})
|
||||||
|
|
||||||
this.textLayer = new PointLayer({})
|
this.textLayer = new PointLayer({})
|
||||||
.source(originData,
|
.source(data,
|
||||||
{
|
{
|
||||||
parser: {
|
parser: {
|
||||||
type: 'json',
|
type: 'json',
|
||||||
@ -399,7 +398,6 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
setLayerAttr (chart) {
|
setLayerAttr (chart) {
|
||||||
|
|
||||||
let defaultSymbol = 'marker'
|
let defaultSymbol = 'marker'
|
||||||
let customAttr = {}
|
let customAttr = {}
|
||||||
let layerStyle = {}
|
let layerStyle = {}
|
||||||
@ -417,7 +415,8 @@ export default {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.myChart.removeAllLayer().then(() => {
|
this.myChart.removeAllLayer().then(() => {
|
||||||
const data = chart.data && chart.data.data || []
|
let data = chart.data && chart.data.data || []
|
||||||
|
data = data.filter(item => item.longitude && item.latitude)
|
||||||
this.pointLayer = new PointLayer({autoFit: true})
|
this.pointLayer = new PointLayer({autoFit: true})
|
||||||
this.pointLayer.source(data, {
|
this.pointLayer.source(data, {
|
||||||
parser: {
|
parser: {
|
||||||
|
Loading…
Reference in New Issue
Block a user