echars 如何做一个只显示一个省的地图??急!!

需求:在一个div中只显示云南省的地图,用echarts做。求一个详细的解答!谢谢了... 需求:在一个div中只显示云南省的地图,用echarts做。求一个详细的解答! 谢谢了 展开
 我来答
二十三页书
2018-02-25 · TA获得超过111个赞
知道答主
回答量:66
采纳率:86%
帮助的人:15万
展开全部

我以显示浙江省的地图为例,写段代码

首先我们需要两个文件:

1、echarts.min.js

2、zhejiang.js

<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <title>echarts图形插件使用</title>
</head>

<body>
<div id="main" style="height:800px;"></div>
<script type="text/JavaScript" src="echarts.min.js"></script>
<script type="text/JavaScript" src="zhejiang.js"></script>
<script type="text/javascript">
        var chart = echarts.init(document.getElementById('main'));
        chart.setOption({
            series: [{
                type: 'map',
selectedMode : 'single',
                map: '浙江',
itemStyle:{  
normal:{label:{show:true}},  
emphasis:{label:{show:true}}  
}
            }]
        });
</script>
</body>

</html>

这样就可以显示浙江省地图了

至于zhejiang.js在哪里获取,可以在github上找到,网页链接,目录为:echarts/map/js/province/

Storm代理
2023-07-25 广告
StormProxies是一家提供动态代理服务器服务的企业,旨在帮助用户更好地管理网络访问和安全。以下是一些关于StormProxies的IP动态代理服务的特点:1. 高匿名性:StormProxies的动态代理服务器具有高匿名性,可以有效... 点击进入详情页
本回答由Storm代理提供
妖艳美好
2018-01-15 · 知道合伙人软件行家
妖艳美好
知道合伙人软件行家
采纳数:66 获赞数:309

向TA提问 私信TA
展开全部
主要html代码
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8" />
<title></title>
</head>

<body>
<div id="main" style="height:800px;"></div>
<script type="text/JavaScript" src="js/echarts.js"></script>
<script type="text/JavaScript" src="js/yunnan.js"></script>
<script type="text/javascript">
echarts.registerMap('yunnan', yunnanJson); //yunnanJson名称取自yunnan.js里的var  yunnanJson变量名

var chart = echarts.init(document.getElementById('main'));
chart.setOption({
title: {
text: '云南省地图', //地图Title
textStyle: {
color: '#016E8B' //对title的样式配置.
}
},
series: [{
type: 'map',
map: 'yunnan',
data: [{
name: '保山市',
selected: true
}]
}]
});
</script>
</body>

</html>

要先下载云南省的JSON数据,然后用一个JS变量保存,如下所示:
var yunnanJson={"type": "FeatureCollection",
"features":
[
{"type": "Feature","properties":{"id":"5308","name":"普洱市","cp":[100.7446,23.4229],"childNum":10},"geometry":{"type":"Polygon","coordinates":[[[99.5142,23.0823],[99.5032,23.1152],[99.5911,23.1702],[99.624,23.1537],[99.624,23.1921],[99.679,23.2471],[99.7998,23.1976],[99.8438,23.2086],[99.8987,23.2526],[100.0195,23.2141],[100.0745,23.2306],[100.0964,23.28],[100.0745,23.3185],[100.0854,23.3459],[100.1074,23.3789],[100.1074,23.4174],[100.1514,23.4723],[100.1843,23.6096],[100.2393,23.6096],[100.2832,23.6426],[100.3162,23.6151],[100.3491,23.6151],[100.437,23.6646],[100.3821,23.6975],[100.3821,23.725],[100.3491,23.7524],[100.3601,23.7799],[100.3491,23.8129],[100.3601,23.8568],[100.4041,23.8733],[100.415,23.9172],[100.3821,23.9941],[100.3601,24.0546],[100.4919,24.0875],[100.5249,24.1974],[100.5029,24.2578],[100.5139,24.2688],[100.5029,24.3347],[100.5029,24.4281],[100.5469,24.472],[100.5249,24.5105],[100.5029,24.5215],[100.4919,24.5764],[100.426,24.6478],[100.4041,24.7083],[100.481,24.7357],[100.5359,24.7083],[100.5688,24.7083],[100.6238,24.7412],[100.6348,24.8236],[100.7446,24.7852],[100.7996,24.7247],[100.8215,24.7357],[100.8765,24.7247],[100.9094,24.7467],[100.9094,24.7247],[100.9424,24.7247],[100.9534,24.6698],[101.0413,24.5544],[101.0413,24.505],[101.0742,24.472],[101.1731,24.3457],[101.239,24.2963],[101.272,24.2908],[101.3489,24.1974],[101.3489,24.1479],[101.3818,24.126],[101.3818,24.0985],[101.4148,24.082],[101.4148,24.0381],[101.4368,24.0271],[101.4478,23.9886],[101.4807,23.9777],[101.4917,23.9447],[101.5356,23.9172],[101.5027,23.8953],[101.4697,23.8458],[101.4368,23.8513],[101.4038,23.8293],[101.4258,23.8074],[101.4258,23.7799],[101.4038,23.7579],[101.4258,23.7195],[101.4587,23.7305],[101.4917,23.7744],[101.5356,23.7854],[101.5686,23.736],[101.5466,23.725],[101.5356,23.6865],[101.5576,23.6755],[101.5796,23.692],[101.6235,23.6371],[101.6785,23.6755],[101.7004,23.6536],[101.6675,23.6151],[101.6785,23.6096],[101.7004,23.5712],[101.7224,23.5657],[101.7114,23.5382],[101.7664,23.4998],[101.7883,23.4558],[101.7664,23.4174],[101.7444,23.4174],[101.7444,23.3954],[101.7664,23.3789],[101.7883,23.3899],[101.8103,23.3734],[101.8323,23.3514],[101.8762,23.3295],[101.8762,23.302],[101.8872,23.291],[101.8762,23.2635],[101.8323,23.2471],[101.8323,23.1647],[101.9421,23.1482],[101.9861,23.1866],[102.0081,23.1647],[101.9971,23.1482],[102.074,23.0988],[102.041,23.0768],[102.052,23.0383],[102.019,22.9889],[101.9641,22.9889],[101.9641,23.0219],[101.8762,23.0109],[101.8542,22.934],[101.7993,22.879],[101.8762,22.8021],[101.8982,22.7966],[101.9202,22.8241],[102.0081,22.7747],[102.052,22.7142],[102.085,22.6538],[102.1948,22.6154],[102.2278,22.6208],[102.2827,22.6044],[102.2937,22.5659],[102.3267,22.5549],[102.2498,22.4615],[102.2607,22.4121],[102.1838,22.4286],[102.1509,22.4231],[102.1509,22.3956],[102.1289,22.4341],[102.041,22.4561],[101.9861,22.4286],[101.9092,22.4341],[101.9092,22.4011],[101.8982,22.3792],[101.8323,22.4176],[101.8103,22.4835],[101.7664,22.5],[101.7334,22.4945],[101.7224,22.478],[101.6675,22.4725],[101.6675,22.4176],[101.6455,22.4066],[101.6675,22.3682],[101.6455,22.3517],[101.6565,22.3297],[101.6125,22.3462],[101.5906,22.3297],[101.5686,22.3627],[101.5137,22.4011],[101.4807,22.511],[101.4368,22.5824],[101.3599,22.5604],[101.3049,22.5275],[101.283,22.5385],[101.228,22.533],[101.1621,22.5494],[101.1072,22.5439],[101.0303,22.5879],[101.0193,22.5769],[100.9753,22.5879],[100.9753,22.5714],[100.9314,22.5824],[100.8875,22.5439],[100.8655,22.5659],[100.7666,22.5714],[100.7556,22.5604],[100.7666,22.5165],[100.7446,22.5275],[100.6567,22.5165],[100.6567,22.4945],[100.6128,22.478],[100.6128,22.4451],[100.5249,22.4615],[100.47,22.4506],[100.437,22.4231],[100.415,22.4396],[100.3821,22.3901],[100.3711,22.3792],[100.3931,22.3627],[100.3821,22.3132],[100.3711,22.2638],[100.3491,22.2473],[100.2283,22.2913],[100.1953,22.2858],[100.2063,22.2638],[100.1733,22.2418],[100.0964,22.2418],[100.0745,22.2144],[100.0525,22.1429],[99.9976,22.1045],[99.9756,22.0496],[99.8767,22.066],[99.8657,22.0551],[99.8767,22.0386],[99.8547,22.0221],[99.7449,22.0715],[99.7119,22.0386],[99.6899,22.0441],[99.6899,22.0605],[99.657,22.1045],[99.613,22.088],[99.5581,22.1155],[99.5251,22.0935],[99.4812,22.132],[99.4153,22.099],[99.3713,22.1045],[99.3604,22.0935],[99.3274,22.0935],[99.2285,22.1155],[99.1626,22.1539],[99.1516,22.1649],[99.2065,22.1704],[99.1846,22.1759],[99.1846,22.1924],[99.2395,22.2473],[99.2395,22.2968],[99.2834,22.3517],[99.2505,22.3846],[99.2944,22.4066],[99.3823,22.4945],[99.3604,22.5275],[99.3823,22.5824],[99.3604,22.6648],[99.3164,22.7362],[99.3823,22.7637],[99.3933,22.8131],[99.4592,22.8461],[99.4482,22.934],[99.5361,22.901],[99.5581,22.912],[99.5581,22.9449],[99.5251,22.9944],[99.5251,23.0548],[99.5142,23.0823]]]}}
]
}
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式