一、运行截图

  

二、代码

  html代码:

 <div style="padding:24px;">

   <p style="font-size: 16px;margin-bottom: 0px;color: #8cc5fe;background-image: url('./../../assets/images/maptitle.png');width: 250px;background-size: contain;background-repeat: no-repeat;height: 36px;line-height: 32px;padding-left: 10px;position: absolute;z-index: 0;">
电站数量:
<label *ngIf="mapComponentConfig.length !=0" style="font-size: 22px;font-family: -webkit-pictograph;color: #1bc3fd;">
<app-led-clockfont [fontValue]="mapComponentConfig.length"></app-led-clockfont>
<!-- mapComponentConfig.length = 397 -->
</label>
<label *ngIf="mapComponentConfig.length ==0" style="font-size: 22px;font-family: -webkit-pictograph;color: #1bc3fd;"><b>--</b></label>
</p>
<div echarts [options]="option1" (chartInit)="onChartInit($event)" class="demo-chart" style="min-height: 600px;"></div>
</div>

  ts代码:

    

 import { Component, OnInit, Input, SimpleChanges } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import * as echarts from 'echarts'; @Component({
selector: 'app-map',
templateUrl: './map.component.html',
styleUrls: ['./map.component.css']
})
export class MapComponent implements OnInit {
@Input() mapComponentConfig;
private map:any ;
public option1:any;
//地图
private data = [];
private provinceDataStatus:any;
private echartsIntance:any;
constructor(private http:HttpClient) {
console.log("我在'地图'组件,构造函数中");
} ngOnInit() {
console.log("我在'地图'组件,初始化函数中");
this.http.get('assets/data/china.json')
.subscribe(geoJson => {
echarts.registerMap('china', geoJson);
if(this.mapComponentConfig){
this.option1 = {
backgroundColor: 'transparent',
title: {
text: '',
// this.mapComponentConfig.count
left: 'left',
textStyle: {
color: '#fff'
}
},
tooltip : {
trigger: 'item'
},
legend: {
orient: 'vertical',
y: 'bottom',
x:'right',
data:['pm2.5'],
textStyle: {
color: '#fff'
}
},
formatter: '{b}',
geo: {
map: 'china',
// map: 'China',
label: {
emphasis: {
show: false
}
},
roam: true,
itemStyle: {
// color:'purple',
borderColor :'black',
borderWidth :5,
normal: {
areaColor: 'black',
// borderColor: 'purple'
},
emphasis: {
areaColor: 'black',
// areaColor: '#2a333d'
}
}
},
series : [
{
name: '',
type: 'effectScatter',
coordinateSystem: 'geo',
data:this.convertData(this.mapComponentConfig.data),
zoom: 3.2,
symbolSize:10,
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'right',
show: false
}
},
itemStyle: {
normal: {
color: '#f4e925',
shadowBlur: 10,
shadowColor: '#333'
}
},
zlevel: 1
}
]
}; }else{
console.log("地图数据请求超时");
};
})
} convertData (data) {
const _self = this;
let res = [];
if(_self.mapComponentConfig){
for (var i = 0; i < _self.mapComponentConfig.length; i++) {
res.push({
name:_self.mapComponentConfig[i].station_name,
value:[_self.mapComponentConfig[i].jingdu,_self.mapComponentConfig[i].weidu]
})
}
return res;
}else{
//Do-nothing
res = [];
return res;
}
}; //图表初始化实例
onChartInit(event) {
this.echartsIntance = event;
// this.echartsIntance.showLoading(this.default);
} ngOnChanges(changes: SimpleChanges): void { if(changes['mapComponentConfig'] !== undefined){
let new_data = this.mapComponentConfig.data;
this.option1 = {
backgroundColor: 'transparent',
title: {
text: '',
left: 'left',
textStyle: {
color: '#fff'
}
},
tooltip : {
trigger: 'item'
},
legend: {
orient: 'vertical',
y: 'bottom',
x:'right',
data:['pm2.5'],
textStyle: {
color: '#fff'
}
},
formatter: '{b}', geo: {
map: 'china',
label: {
emphasis: {
show: false
}
},
roam: true,
itemStyle: {
borderColor :'black',
borderWidth :5,
normal: {
areaColor:'black',
},
emphasis: {
areaColor: 'black',
}
}
},
series : [
{
name: '',
type: 'effectScatter',
coordinateSystem: 'geo',
data:this.convertData(new_data),
zoom: 3.2,
symbolSize:10,
showEffectOn: 'render',
rippleEffect: {
brushType: 'stroke'
},
hoverAnimation: true,
label: {
normal: {
formatter: '{b}',
position: 'right',
show: false
}
}, itemStyle: {
normal: {
color: '#f4e925',
// color:'#e96c1d',
shadowBlur: 10,
shadowColor: '#333'
}
},
zlevel: 1
}
]
}; // if(this.echartsIntance){
// console.log("this.echartsIntance:",this.echartsIntance);
// this.echartsIntance.hideLoading();
// }else{
// //Do-nothing
// } }else{
console.log("地图数据加载超时");
} } }

ngx-echart地图的更多相关文章

  1. Echart - 地图散点图(服务网点图)的实现

    Echart是百度开发的一个javascript图表库,可以流程运行于pc和移动端,底层依赖轻量级的 Canvas 类库 ZRender. ECharts 提供了常规的折线图,柱状图,散点图,饼图,K ...

  2. echart地图下钻

    需求:展示中国地图,鼠标点击显示对应的省份 在echart的github上下载需要的 地图文件China.js,各个省份的json文件 遇到的问题:直接在浏览器打开报错,跨域问题,用webstrom打 ...

  3. Echart地图城市用json返回格式

    用Echarts中,使用地图的series部分中展示城市如果用json返回数据的话,js不能直接用字符串使用.需要处理一下. php中的部分 json返回的数据 js中获取json信息 用ajax实现 ...

  4. 百度Echart 地图

    使用百度地图做一个全国地图数据分析的功能,如下图 代码 <%@ Page Language="C#" AutoEventWireup="true" Cod ...

  5. Echart 地图实例

    1.地图实例 function func_InEchart() { require.config({ paths: { echarts: '../Scripts/echart2/echarts' }, ...

  6. echart 地图

    <%@ page language="java" import="java.util.*" pageEncoding="utf-8"% ...

  7. echarts 点击方法总结,点任意一点获取点击数据,在多图联动中用生成标线举例

    关于点击(包括左击,双击,右击等)echarts图形任意一点,获取相关的图形数据,尤其是多图,我想部分人遇到这个问题一直很头大.下面我用举例说明,如何在多图联动基础上,我们点击点击任意一个图上任意一点 ...

  8. Echarts 南海诸岛简图显示位置调整

        最近需要echart同时显示海南岛和南海诸岛,开始想寻找南海诸岛的数据,经过查找,这种简图数据是没有的(china.js地图数据一一找过了),下图是echarts的一些示例,没有满足我们的要求 ...

  9. echarts 点击方法总结,点任意一点获取点击数据,举例说明:在多图联动中点击绘制标线

    关于点击(包括左击,双击,右击等)echarts图形任意一点,获取相关的图形数据,尤其是多图,我想部分人遇到这个问题一直很头大.下面我用举例说明,如何在多图联动基础上,我们点击任意一个图上任意一点,在 ...

  10. canvas实现平面迁徙图

    前言 最近在做自己维护的一个可视化工具的时候,在添加基于echart的雷达图的时候,按照echart官网案例写完发现在自己项目中无法正常运行,排查了一番发现是我项目中echart的版本太低.找到问题原 ...

随机推荐

  1. IDEA运行android项目一直是同一个apk

    1.IDEA运行android项目时不像eclipse和android studio那样直接运行,IDEA需要设置Artifacts,这样每次运行的时候它才能重新编译,以下附上步骤! 这样就可以了.

  2. [au3]批量输入号码程序

    批量输入号码程序 这个文件可以随时产生一个剪贴板文字的文本文件,以供其他程序读取. 这个程序修改了许多次了,主要是针对网络延迟的问题. 最终找到了解决方案:探测输入的界面的反馈信息,也就是反馈的颜色. ...

  3. first one

    我说一句话你就知道我是干什么的 hello world

  4. 591. Tag Validator

    Given a string representing a code snippet, you need to implement a tag validator to parse the code ...

  5. Java 代码需要使用转义符的地方

    1.正则表达式特殊字符 Java 代码中使用到正则表达式里的特殊字符需要使用转义符 \ 进行转义 . ? * + ! ^ $ [ ] ( ) \ 因为反斜线 \ 也是特殊字符,所以转义需双反斜线 \\ ...

  6. 为网站添加emoji表情的支持

    项目框架 React.js + webpack + ES6 + Jquery 需求描述 使用客户端的用户常常喜欢发emoji表情,而在浏览器打开网页版的时候,emoji表情不能正常显示.在chrome ...

  7. Appium同时连接多台手机进行测试(多线程)

    作为测试小白,当时遇到了N多问题: 开启多线程后,发现app启动后,用例就停止了:且启动app对应的手机不能正确对应,用例中是A手机跑A用例,结果启动了B手机跑A用例报错. 主要原因:Appium S ...

  8. Java异步执行多个HTTP请求的例子(需要apache http类库)

    直接上代码 package org.jivesoftware.spark.util; import java.io.IOException; import java.util.concurrent.C ...

  9. 【LeetCode】14. 最长公共前缀

    题目 编写一个函数来查找字符串数组中的最长公共前缀.如果不存在公共前缀,返回空字符串 "". 示例 1:输入: ["flower","flow&quo ...

  10. 高手速成android开源项目【developer篇】

    主要介绍和Android开发工具和测试工具相关的开源项目. Buckfacebook开源的Android编译工具,效率是ant的两倍.主要优点在于:(1) 加快编译速度,通过并行利用多核cpu和跟踪不 ...