1. 程式人生 > 實用技巧 >離線地圖開發之標註柱狀圖特效(原始碼)

離線地圖開發之標註柱狀圖特效(原始碼)

原始碼:來源http://www.bigemap.com/offlinemaps/demo/echarts_bar.html

<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8' />
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<!--
以下CSS地址請在安裝軟體了替換成本地的地址
CSS地址請使用:
http://localhost:9000/bigemap.js/v2.1.0/bigemap.css

軟體下載地址 http://www.bigemap.com/reader/download/detail201802017.html
-->
<link href='http://www.bigemap.com:9000/bigemap.js/v2.1.0/bigemap.css' rel='stylesheet' />
<!--
JS地址請使用:
http://localhost:9000/bigemap.js/v2.1.0/bigemap.js
-->
<script src='http://www.bigemap.com:9000/bigemap.js/v2.1.0/bigemap.js'></script>

<script type="text/javascript" src="https://gallerybox.echartsjs.com/dep/echarts/latest/echarts.min.js"></script>
<script src="/Public/offline/iclient/js/iclient9.min.js"></script>
<style>
body { margin: 0; padding: 0;}
#map { position: absolute; top: 0; bottom: 0; width: 100%; }

</style>
<title>Google Map Streets</title>
</head>
<body>
<div id='map'></div>
<script>
//軟體配置資訊地址,軟體安裝完成之後使用本地地址,如:http://localhost:9000
BM.Config.HTTP_URL = 'http://www.bigemap.com:9000';
// 在ID為map的元素中例項化一個地圖,並設定地圖的ID號為 bigemap.googlemap-streets,ID號程式自動生成,無需手動配置,並設定地圖的投影為百度地圖 ,中心點,預設的級別和顯示級別控制元件
var map = BM.map('map','bigemap.googlemap-satellite', { center: [32, 108], zoom: 4, zoomControl: true });
let option = {
legend: {
data: ['降雨量', '徑流量'],
align: 'left'
},
toolbox: {
feature: {
magicType: {
type: ['stack', 'tiled']
},
saveAsImage: {
pixelRatio: 2
}
}
},
tooltip: {},
xAxis: {
data: ['週一','週二','週三','週四','週五','週六','週日'],
silent: false,
splitLine: {
show: false
}
},
yAxis: {},
series: [{
name: '降雨量',
type: 'bar',
animationDelay: function (idx) {
return idx * 10;
}
}, {
name: '徑流量',
type: 'bar',
animationDelay: function (idx) {
return idx * 10 + 100;
}
}],
animationEasing: 'elasticOut',
animationDelayUpdate: function (idx) {
return idx * 5;
}
};
var div = BM.DomUtil.create('div');
var chart = echarts.init(div, '', {
width: 500,
height: 300
});
chart.setOption(option);
let places=[{"name":"甘肅","position":[36.03,103.73]},{"name":"青海","position":[36.56,101.74]},{"name":"四川","position":[30.67,104.06]},{"name":"河北","position":[38.03,114.48]},{"name":"雲南","position":[25.04,102.73]},{"name":"貴州","position":[26.57,106.71]},{"name":"湖北","position":[30.52,114.31]},{"name":"河南","position":[34.76,113.65]},{"name":"山東","position":[36.65,117]},{"name":"江蘇","position":[32.04,118.78]},{"name":"安徽","position":[31.86,117.27]},{"name":"浙江","position":[30.26,120.19]},{"name":"江西","position":[28.68,115.89]},{"name":"福建","position":[26.08,119.3]},{"name":"廣東","position":[23.16,113.23]},{"name":"湖南","position":[28.21,113]},{"name":"海南","position":[20.02,110.35]},{"name":"遼寧","position":[41.8,123.38]},{"name":"吉林","position":[43.88,125.35]},{"name":"黑龍江","position":[45.75,126.63]},{"name":"山西","position":[37.87,112.53]},{"name":"陝西","position":[34.27,108.95]},{"name":"臺灣","position":[25.03,121.3]},{"name":"北京","position":[39.92,116.46]},{"name":"上海","position":[31.22,121.48]},{"name":"重慶","position":[29.59,106.54]},{"name":"天津","position":[39.13,117.2]},{"name":"內蒙古","position":[40.82,111.65]},{"name":"廣西","position":[22.84,108.33]},{"name":"西藏","position":[29.97,91.11]},{"name":"寧夏","position":[38.47,106.27]},{"name":"新疆","position":[43.77,87.68]},{"name":"香港","position":[22.28,114.17]},{"name":"澳門","position":[22.19,113.54]}];
places.map(function (v) {
BM.marker(v.position).bindPopup(function () {
var city = v.name;
var data1 = [];
var data2 = [];
for (var i = 0; i < 7; i++) {
var data = Math.random().toFixed(2);
data1.push(data);
data2.push(data * (Math.random() + 1.5));
}
chart.setOption({
title: {
text: city,
subtext: '資料純屬虛構',
},
series: [
{
name: '降雨量',
data: data1
},
{
name:'徑流量',
data: data2
}
]
});
return chart.getDom();
},{maxWidth:600}).addTo(map);
});
</script>
</body>
</html>