Google Map extension for Apache ECharts
中文说明
Online example on CodePen
This is a Google Map extension for Apache ECharts which is used to display visualizations such as Scatter, Lines, Heatmap, and Pie.
Examples
Scatter
Lines
Heatmap
Pie
Installation
npm install echarts-extension-gmap --save
Import
Import packaged distribution file echarts-extension-gmap.min.js
and add Google Map API script and ECharts script.
<script src="https://maps.googleapis.com/maps/api/js?key={key}"></script>
<script src="/path/to/echarts.min.js"></script>
<script src="dist/echarts-extension-gmap.min.js"></script>
You can also import this extension by require
or import
if you are using webpack or any other bundler.
require('echarts');
require('echarts-extension-gmap');
import * as echarts from 'echarts';
import 'echarts-extension-gmap';
Or use a CDN
jsdelivr
<script src="https://cdn.jsdelivr.net/npm/echarts-extension-gmap/dist/echarts-extension-gmap.min.js"></script>
unpkg
<script src="https://unpkg.com/echarts-extension-gmap/dist/echarts-extension-gmap.min.js"></script>
This extension will register itself as a component of echarts
after it is imported.
Usage
This extension can be configured simply like geo.
option = {
gmap: {
center: [108.39, 39.9],
zoom: 4,
renderOnMoving: true,
echartsLayerZIndex: 2019,
roam: true
},
series: [
{
type: 'scatter',
coordinateSystem: 'gmap',
data: [[120, 30, 8], [120.1, 30.2, 20]],
encode: {
value: 2,
lng: 0,
lat: 1
}
}
]
};
var gmap = chart
.getModel()
.getComponent('gmap')
.getGoogleMap();
var marker = new google.maps.Marker({ position: gmap.getCenter() });
marker.setMap(gmap);