Merge pull request #6312 from dataease/pr@dev@fix_symbol_map_empty

fix: 符号地图数据包涵经纬度为空的记录label无法展示
This commit is contained in:
fit2cloud-chenyw 2023-10-23 17:07:15 +08:00 committed by GitHub
commit e6402ff9b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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: {