一、运行截图

  

二、代码

  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. Linux下gcc编译控制动态库导出函数小结

    根据说明文档“How To Write Shared Libraries"介绍, 有四种方法: 1. 在方法声明定义时,加修饰:__attribute__((visibility(" ...

  2. 解决 asp.net core 中下载 exe 文件返回 404

    在 StartUp 中的 Configure 方法添加如下代码即可 app.UseStaticFiles(new StaticFileOptions() { ContentTypeProvider = ...

  3. HTML+CSS实现页面豆腐块布局和图片居中

    <!DOCTYPE html> <html> <head lang="en"> <meta http-equiv="Conten ...

  4. Python模块学习 - fabric

    简介 fabric是一个Python的库,同时它也是一个命令行工具.使用fabric提供的命令行工具,可以很方便地执行应用部署和系统管理等操作. fabric依赖于paramiko进行ssh交互,fa ...

  5. Java 中的伪共享详解及解决方案

    1. 什么是伪共享 CPU 缓存系统中是以缓存行(cache line)为单位存储的.目前主流的 CPU Cache 的 Cache Line 大小都是 64 Bytes.在多线程情况下,如果需要修改 ...

  6. vue项目中在同一页面多次引入同一个echarts图表的自适应问题

    在父组件页面引入两次该图表子组件显示的效果: 由于是百分比宽高,所以在窗口发生变化时,需要让图表也跟着自适应,所以才出现了本次讨论的问题啦. 先看下完整的图表子组件代码(在父组件就是直接引入,不需要传 ...

  7. spring boot 集成jsp

    刚开始操作的时候,遇到了个问题,在这记录一下.(因为自己是个新手,对maven项目结构不了解) 1.大概创建步骤如下 File-New-Project-Spring Initializr ,type选 ...

  8. appium-doctor

    1.   I installed appium-1.5.3.dmg But when I click the stethoscope button the Appium is show error : ...

  9. Python日常实践(1)——SQL Prompt的Snippets批量整理

    引言 个人平时在写sql脚本的时候会使用到SQL Prompt这款插件,除了强大的智能提示和格式化sql语句功能,我还喜欢使用Snippets代码段功能.比如我们可以在查下分析器输入ssf后按Tab键 ...

  10. Zabbix系列之六——添加web监测

    zabbix提供了web监测功能,监控到站点的响应时间,还可以根据站点返回的状态码,或者响应时间做报警,列入服务保证官网确打不开等现象. 官网地址:https://www.zabbix.com/doc ...