一、运行截图

  

二、代码

  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. sqrt()函数对素数判断的优化

    素数是只有1和本身能整除的整数.所以在求素数的时候,要将素数与1到素数本身中间的所有整数都相除,看是否有整除的数,如果有,那肯定不是素数了.但是从算法上考虑,为了减少重复量,开平方后面的数就不用相除了 ...

  2. Vuejs——(11)组件——slot内容分发

    版权声明:出处http://blog.csdn.net/qq20004604   目录(?)[+]   本篇资料来于官方文档: http://cn.vuejs.org/guide/components ...

  3. MFS 服务扫描与爆破

    MSF 服务发现 常用来发现局域网内,的常见服务,比如HTTP,FTP,TELNET等. MSF模块搜索: [root@localhost ~]# msfconsole msf5 > searc ...

  4. fiddler 使用方法汇总

    作为网络开发人员,怎能不使用一些抓包工具呢?fiddler是个不错的选择. 不过,一般情况下,我们往往使用浏览器自带的控制台的[网络]选项就可以达到查看数据的通信情况了,当然,一些浏览器不容易捕捉的事 ...

  5. python中匿名函数lambda

    简单来说,编程中提到的 lambda 表达式,通常是在需要一个函数,但是又不想费神去命 名一个函数的场合下使用,也就是指匿名函数. 先看它的几个用法: map( lambda x: x*x, [y f ...

  6. 机器学习技法笔记:05 Kernel Logistic Regression

    Roadmap Soft-Margin SVM as Regularized Model SVM versus Logistic Regression SVM for Soft Binary Clas ...

  7. 学习react

    推荐资源: 一位react的最初构建者写的学习react的建议,这是翻译过的http://www.360doc.com/content/16/0129/07/13518188_531384175.sh ...

  8. 关于appendChild和insertBefore appendTo()和append

    appendChild和insertBefore(原生js) appendTo()和append(jquery)

  9. vertical-align_CSS参考手册_web前端开发参考手册系列

    该属性定义行内元素的基线相对于该元素所在行的基线的垂直对齐.允许指定负长度值和百分比值.这会使元素降低而不是升高.在表单元格中,这个属性会设置单元格框中的单元格内容的对齐方式. <!DOCTYP ...

  10. Android的Fragment中的互相通信-桥梁activity

    Android的Fragment中的互相通信-桥梁activity 效果图如下: 项目结构图如下: Fragment1: package com.demo.fragmenttongxin; impor ...