试过了offset和很多Api,都无法实现label居中
后来无意中发现,原来在geojson注册的时候,可以定义 properties.cp 属性,实现文本的坐标自定义,实现居中。
echarts.registerMap('china', {
"type": "FeatureCollection",
"features": [{
"id": "650000",
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [],
"encodeOffsets": [[88824, 50096]]
},
"properties": {
"cp": [87.617733, 43.792818],
"name": "新疆",
"childNum": 1
}
}],
"UTF8Encoding": true
});