Echarts 绘制到区县街道的地图

【1】获取街道的kml文件

正常绘制到省市县可以用阿里云 DataV.GeoAtls地理小工具获取坐标数据即可,但是这个是不到区县街道的坐标,如果需要绘制到街道的坐标,需要借助Bigemap GIS

依次下载所需街道的kml文件。

【2】组合kml坐标信息

使用geojson.io在线工具将所有的mkl导入生成到区县的坐标数据

依次把下载的kml文件导入,全都导入完成后,直接将右侧的json数据cv

然后放到json文件中然后引用就好。

【3】使用效果

部分代码:

<script type="text/javascript" src="js/tianqiao.js"></script>

//初始化echarts实例,TIANQIAO_MAP_DATA是坐标数据的变量
				echarts.registerMap('天桥区', TIANQIAO_MAP_DATA);
				var mapEchart = echarts.init(document.getElementById('mapEchart'));
				var option = {
					title: {
						text: "天桥区资产分布图",
						// subtext: "各区域资产间数",
						textStyle: {
							color: "white",
						},
						subtextStyle: {
							color: "white",
						},
						top: 10,
						left: "center"
					},
					tooltip: {  // 鼠标悬浮标注时展示的信息
						trigger: 'item',
						borderColor: 'green',
						formatter: function(params) {
							var data = params.data
							var str = `名称:${data.name}<br/>资产:${data.zcNum}间<br/>负责人:张三<br/>联系方式:134xxxxxxxx<br/>地址:xxx街道100号xxx楼xxx室`;
							return str;
						} 
					},
					toolbox: {
						show: true,
						top: 10,
						right: 10,
						feature: {
							restore: {
								title: '刷新'
							},
							saveAsImage: {
								title: '下载'
							}
						},
						iconStyle: {
							borderColor: 'white',
							borderWidth: 2
						}
					},
					geo: {  // 地图信息配置
						type: 'map',
						map: '天桥区',
						roam: true,
						top: 90,
						zoom: 1.1,
						scaleLimit: {
							min: 1,
							max: 5
						},
						label: {
							show: true,
							fontSize: 8,
							color: "black"
						},
						itemStyle: {
							areaColor: "#7cf1de"
						},
						emphasis: {
							label: {
								show: true,
								fontSize: 16
							},
							itemStyle: {
								areaColor: "#7cf1de",
								borderWidth: 2,
								shadowBlur: 20,
								shadowColor: "rgba(0, 0, 0, 0.5)",
								borderColor: "#fff",
							}
						}
					},
					series: [
						{ // 标注信息配置
							// type: "scatter",
							type: "custom",	// 自定义图标
							coordinateSystem: "geo",
							// symbol: "circle",
							symbolSize: 44,
							label: {
								show: true,
								color: "#fff",
								formatter: function(params) {
									return params.data.zcNum;
								}
							},
							itemStyle: {
								color: "#fe2321"
							},
							data: [
								{
									name: "xxx楼盘1",
									value: [116.97383095672191, 36.84801295303867],
									zcNum: 200
								},
								{
									name: "xxx楼盘2",
									value: [116.90048462154695, 36.81075951381215],
									zcNum: 180
								},
								{
									name: "xxx楼盘3",
									value: [117.02535907826886, 36.81946358839779],
									zcNum: 160
								},
								{
									name: "xxx楼盘4",
									value: [116.92648079097606, 36.771765259668506],
									zcNum: 140
								},
								{
									name: "xxx楼盘5",
									value: [117.03325077255984, 36.777335867403316],
									zcNum: 180
								},
								{
									name: "xxx楼盘6",
									value: [116.96268974125229, 36.71988897513812],
									zcNum: 180
								},
								{
									name: "xxx楼盘7",
									value: [116.97011721823203, 36.68959879558011],
									zcNum: 180
								},
								{
									name: "xxx楼盘8",
									value: [117.02860859944751, 36.693776751381215],
									zcNum: 180,
								},
								{
									name: "xxx楼盘9",
									value: [116.99100699723755, 36.764105674033146],
									zcNum: 180
								},
								{
									name: "xxx楼盘10",
									value: [116.97197408747697, 36.807626046961325],
									zcNum: 180
								}
							],
							renderItem(params, api) {
								const coord = api.coord([
									api.value(0, params.dataIndex),
									api.value(1, params.dataIndex)
								]);
								const circles = [];
								for (let i = 0; i < 5; i++) {
									circles.push({
										type: 'circle',
										shape: {
											cx: 0,
											cy: 0,
											r: 30
										},
										style: {
											stroke: '#5dc2fe',
											fill: 'none',
											lineWidth: 2
										},
										// Ripple animation
										keyframeAnimation: {
											duration: 5000,
											loop: true,
											delay: (-i / 4) * 4000,
											keyframes: [
												{
													percent: 0,
													scaleX: 0,
													scaleY: 0,
													style: {
														opacity: 1
													}
												},
												{
													percent: 1,
													scaleX: 1,
													scaleY: 0.4,
													style: {
														opacity: 0
													}
												}
											]
										}
									});
								}
								return {
									type: 'group',
									x: coord[0],
									y: coord[1],
									children: [
										...circles,
										{
											type: 'path',
											shape: {
												d: 'M16 0c-5.523 0-10 4.477-10 10 0 10 10 22 10 22s10-12 10-22c0-5.523-4.477-10-10-10zM16 16c-3.314 0-6-2.686-6-6s2.686-6 6-6 6 2.686 6 6-2.686 6-6 6z',
												x: -10,
												y: -35,
												width: 20,
												height: 40
											},
											style: {
												fill: '#3c9fd9'
											},
											// Jump animation.
											keyframeAnimation: {
												duration: 4500,
												loop: true,
												delay: Math.random() * 2500,
												keyframes: [
													{
														y: -10,
														percent: 0.5,
														easing: 'cubicOut'
													},
													{
														y: 0,
														percent: 1,
														easing: 'bounceOut'
													}
												]
											}
										}
									]
								};
							}
						}
					]
				}

  • 5
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
function getGzMap(_data) { if (_chinaMap == undefined) { var dom = document.getElementById("container"); _chinaMap = echarts.init(dom); _chinaMap.on('click', function(params) { console.log(params); var _type = params.seriesType; if (_type == "map") { //window.parent.aaa('aa') //调用父页面方法 } else if (_type == "effectScatter") { window.parent.showMap(); } }) } var option = { backgroundColor: 'rgba(0,0,0,0)', visualMap: { type: 'piecewise', show: false, min: 0, max: 300, splitNumber: 3, itemWidth: 10, itemHeight: 10, itemGap: 5, seriesIndex: [1], pieces: [ { min: 0, max: 100, label: '优' }, { min: 101, max: 200, label: '良' }, { min: 201, max: 300, label: '高风险' } ], //color: ['#FA4D08', '#4BD94F', '#FBD32B'], //红、绿、黄 color: ['#F8DAE6', '#FEF9B5', '#B0D8B3'], //红、黄、绿 textStyle: { color: '#9EA8B1', fontSize: 10 } }, tooltip: { formatter: '{b}' }, geo: { map: 'guangdong', roam: true, aspectScale: 1, zoom: 1.5, layoutCenter: ['55%', '40%'], layoutSize: 500, label: { normal: { show: true }, emphasis: { show: true } }, itemStyle: { normal: { areaColor: '#323c48', borderColor: '#111', borderColor: '#3BB4DF', shadowColor: '#25A3FC', shadowBlur: 10 }, emphasis: { areaColor: '#ddb926' } } }, series: [{ type: 'effectScatter', coordinateSystem: 'geo', data: unitData, symbolSize: 10, symbol: 'image://../../../../Content/images/One/fire.png', //symbolRotate: 35, rippleEffect: { period: 4, scale: 5, brushType: 'fill', }, label: { normal: { formatter: '{b}', position: 'right', show: false }, emphasis: { show: false } }, itemStyle: { normal: { color: '#fff' } } }, { name: '', type: 'map', geoIndex: 0, mapType: 'guangdong', // 自定义扩展图表类型 label: { normal: { show: true, } }, itemStyle: { normal: { label: { show: true, fontSize: 10, color: '#111' }, shadowColor: '#ddb926', shadowBlur: 5, }, emphasis: { label: { show: true }, shadowColor: 'rgba(0, 0, 0, 0.5)', shadowBlur: 10 } }, data: _data }, { type: 'effectScatter', coordinateSystem: 'geo', data: windData, symbolSize: 10, symbol: 'image://../../../../Content/images/One/wind.png', //symbolRotate: 35, rippleEffect: { period: 4, scale: 5, brushType: 'fill', }, label: { normal: { formatter: '{b}', position: 'right', show: false }, emphasis: { show: false } }, itemStyle: { normal: { color: '#fff' } } }, ] }; $.getJSON('../../MapCN/guangdong.json', function(chinaJson) { echarts.registerMap('guangdong', chinaJson); _chinaMap.setOption(option, true); }); }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值