New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

中国地图,省份名称重叠 #4379

Closed
MShineRay opened this Issue Nov 2, 2016 · 6 comments

Comments

Projects
None yet
4 participants
@MShineRay

MShineRay commented Nov 2, 2016

问题简述 (One-line summary)

中国地图,省份名称重叠
江苏省和安徽省,省份名称存在折叠,请问有没有API接口重新定位某一个省的名称显示位置?

版本及环境 (Version & Environment)

  • ECharts 版本 (ECharts version):v3.2.3
  • 浏览器类型和版本 (Browser version):所有主流浏览器
  • 操作系统类型和版本 (OS Version):Windows10

重现步骤 (Steps to reproduce)

1.echarts官网,中国地图demo【链接:http://echarts.baidu.com/demo.html#map-china】
2.echarts官网,问题交流【链接:http://gallery.echartsjs.com/editor.html?c=xHy_Iqa8ll&comment=0】

期望结果 (Expected behaviour)

省份名称显示位置可自定义,避免重叠

可能哪里有问题 (What went wrong)

ECharts配置项 (ECharts option)

option = {

}

其他信息 (Other comments)

@MShineRay

This comment has been minimized.

Show comment
Hide comment
@MShineRay

MShineRay Nov 2, 2016

找到了笨办法:直接修改china.js中
"properties":{"cp":[119.767413,33.041544],"name":"江苏","childNum":1}
cp的值,根据调试结果来看,cp应该代表x,y轴定位相关信息。修改副作用未知。。。。。。。

MShineRay commented Nov 2, 2016

找到了笨办法:直接修改china.js中
"properties":{"cp":[119.767413,33.041544],"name":"江苏","childNum":1}
cp的值,根据调试结果来看,cp应该代表x,y轴定位相关信息。修改副作用未知。。。。。。。

@pissang

This comment has been minimized.

Show comment
Hide comment
@pissang

pissang Nov 2, 2016

Contributor

@MShineRay 这是正确的办法,也可以 echarts.getMap('china') 后修改已经加载的地图的数据

Contributor

pissang commented Nov 2, 2016

@MShineRay 这是正确的办法,也可以 echarts.getMap('china') 后修改已经加载的地图的数据

@pissang pissang added the question label Nov 2, 2016

@MShineRay

This comment has been minimized.

Show comment
Hide comment
@MShineRay

MShineRay Nov 2, 2016

@pissang 非常感谢指点。大体整理了一下代码,这个应该是比较正确的方案了:

var chinaMapInfoObj = document.getElementById(‘mianid‘’);
var chinaMap = echarts.init(chinaMapInfoObj);
var chinaEchartsObj = echarts.getMap('china');
var geoJSONChina = chinaEchartsObj.geoJson;
var allDefProvince = geoJSONChina.features;
for(var i=0,len=allDefProvince.length; i<len; i++){
       var sglProvinceProperties = allDefProvince[i].properties;
       var sglProvinceName = sglProvinceProperties.name;
       switch(sglProvinceName){
              case '新疆':
                       sglProvinceProperties.cp[0]=87.617733;
                       sglProvinceProperties.cp[1]=41.792818;
                       break;
               case '青海'://def:101.778916,36.623178
                        sglProvinceProperties.cp[0]=97.617733;
                        sglProvinceProperties.cp[1]=36.623178;
                       break;
                 case '江苏'://def:118.767413,32.041544
                        sglProvinceProperties.cp[0]=119.767413;
                        sglProvinceProperties.cp[1]=33.041544;
                        break;
        }
}
option.echarts.registerMap('china', geoJSONChina, {});

相关资料:
echarts API

MShineRay commented Nov 2, 2016

@pissang 非常感谢指点。大体整理了一下代码,这个应该是比较正确的方案了:

var chinaMapInfoObj = document.getElementById(‘mianid‘’);
var chinaMap = echarts.init(chinaMapInfoObj);
var chinaEchartsObj = echarts.getMap('china');
var geoJSONChina = chinaEchartsObj.geoJson;
var allDefProvince = geoJSONChina.features;
for(var i=0,len=allDefProvince.length; i<len; i++){
       var sglProvinceProperties = allDefProvince[i].properties;
       var sglProvinceName = sglProvinceProperties.name;
       switch(sglProvinceName){
              case '新疆':
                       sglProvinceProperties.cp[0]=87.617733;
                       sglProvinceProperties.cp[1]=41.792818;
                       break;
               case '青海'://def:101.778916,36.623178
                        sglProvinceProperties.cp[0]=97.617733;
                        sglProvinceProperties.cp[1]=36.623178;
                       break;
                 case '江苏'://def:118.767413,32.041544
                        sglProvinceProperties.cp[0]=119.767413;
                        sglProvinceProperties.cp[1]=33.041544;
                        break;
        }
}
option.echarts.registerMap('china', geoJSONChina, {});

相关资料:
echarts API

@lijun007

This comment has been minimized.

Show comment
Hide comment
@lijun007

lijun007 Jun 7, 2017

我做地图下钻,很多市级地图的城市名称也是重叠的,不可能每一个市都去手动改cp的值,有没有什么办法能够解决?

lijun007 commented Jun 7, 2017

我做地图下钻,很多市级地图的城市名称也是重叠的,不可能每一个市都去手动改cp的值,有没有什么办法能够解决?

@llyuanq

This comment has been minimized.

Show comment
Hide comment
@llyuanq

llyuanq Jun 26, 2018

4.1版本的省地图中,市边界的js相关,没有了吗?

llyuanq commented Jun 26, 2018

4.1版本的省地图中,市边界的js相关,没有了吗?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment