JavaScript高德地图中绘制echarts图表随地图移动**
先上效果图
实现方法如下:
使用高德地图“信息窗体”,信息窗体AMap.InfoWindow的属性content,在content中创建一个div元素,在此div元素中绘制echarts图表。
content内容如下
infoWindow = new AMap.InfoWindow({
content: "<div id='echartBox'></div>" //使用默认信息窗体框样式,显示信息内容
});
注意在样式中定义宽高,否则图表渲染看不到
#echartBox{
width: 400px;
height: 400px;
}
完整代码如下
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>自定义样式信息窗体</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
<style>
html, body, #container {
height: 100%;
width: 100%;
}
.custom-input-card{
width: 18rem;
}
.custom-input-card