赞
踩
.agency_information { width: 250px; padding: 5px 0; background: transparent; border-radius: 5px; } .agency_title { min-width: 150px; height: auto; margin-bottom: 6px; font-size: 14px; color: #ffffff; font-weight: normal; text-align: center; } .agency_type { color: #fe0101; } .agency_info_row { box-sizing: border-box; display: flex; justify-content: flex-start; align-items: center; width: 100%; height: auto; padding-left: 10px; background: #ffffff33; margin-bottom: 4px; font-size: 12px; color: #ffffff; font-weight: normal; } .agency_info_row > label:first-child { width: 60px; height: auto; margin-right: 20px; text-align: left; } <div class="map" id="map" style="width:900px;height:900px;"></div> function ecMapServicer(name) { var uploadedDataURL = "json/wuhan.json"; // 基于准备好的dom,初始化echarts实例 const myChart = echarts.init(document.getElementById(name)); /* {name:'武汉', geoCoord:[114.31, 30.52]}, x-y坐标轴起点[113.45, 29.95] */ var data_type_1 = [{ type: "一类", name: "五零四文化广场", value: [114.31, 30.1222, 120] }, { type: "一类", name: "五零四文化广场", value: [114.41, 30.32, 120] }, { type: "一类", name: "五零四文化广场", value: [114.39, 30.52, 120] }, { type: "一类", name: "五零四文化广场", value: [114.73, 30.72, 120] } ]; var data_type_2 = [{ type: "二类", name: "五零四文化广场", value: [114.2133, 30.1222, 120] }, { type: "二类", name: "五零四文化广场", value: [114.01, 30.3222, 120] }, { type: "二类", name: "五零四文化广场", value: [114.59, 30.82, 120] }, { type: "二类", name: "五零四文化广场", value: [114.73, 30.72, 120] } ]; var data_type_3 = [{ type: "三类", name: "五零四文化广场", value: [114.27, 31.292, 120] }, { type: "三类", name: "五零四文化广场", value: [114.21, 30.72, 120] }, { type: "三类", name: "五零四文化广场", value: [114.429, 30.12, 120] }, { type: "三类", name: "五零四文化广场", value: [114.73, 30.62, 120] } ]; // 显示加载动画 myChart.showLoading(); $.getJSON(uploadedDataURL, null, function (data) { echarts.registerMap("mapData", data); myChart.hideLoading(); option = { color: ["#91c7ae", "#749f83", "#ca8622"], //颜色组 tooltip: { trigger: "item", show: true, padding: 0, backgroundColor: "#ffffff33", formatter: function (params) { var str = ` <div class="agency_information"> <div class="agency_title"> ${params.name} <label class="agency_type">(${params.data.type})</label> </div> <div class="agency_info_row"> <label>建立时间:</label><label> 2007(使用)</label> </div> <div class="agency_info_row"> <label>负责人:</label><label> 张建华 </label> </div> <div class="agency_info_row"> <label>床位数: </label><label> 200 </label> </div> <div class="agency_info_row"> <label>联系方式:</label><label> 125697415266</label> </div> <div class="agency_info_row"> <label>地址:</label><label> 武汉市xxxxxxxx</label> </div> </div> `; return str; /* if (typeof params.value[2] == "undefined") { return params.name + " : " + params.value; } else { return params.name + " : " + params.value[2]; } */ } }, grid: { top: 100 }, legend: { orient: "vertical", icon: "pain", right: '10%', bottom: '10%', itemWidth: 20, itemHeight: 12, align: "left", textStyle: { color: "#fff", fontSize: 12 }, data: ["一类", "二类", "三类"] }, xAxis: { show: false }, yAxis: { show: false }, geo: { show: true, map: "mapData", label: { normal: { show: false }, emphasis: { show: false } }, zoom: 1.2, roam: true, itemStyle: { areaColor: "#1A2B75", borderColor: "#3fdaff", borderWidth: 1 }, emphasis: { itemStyle: { areaColor: "#2B91B7" } } }, series: [ // 一类 { name: "一类", type: "scatter", coordinateSystem: "geo", symbol: "image://img/icon_location_1.png",//自行找图标 symbolSize: [14, 16], label: { normal: { show: false, backgroundColor: "#0D1151", position: "right", color: "#ffffff", fontSize: "14", padding: 20 }, emphasis: { show: false } }, itemStyle: { normal: { color: "#00A0E9", //控制图例和地图标记点的颜色 borderWidth: 2 } }, data: data_type_1 }, // 二类 { name: "二类", type: "scatter", coordinateSystem: "geo", symbol: "image://img/icon_location_2.png", symbolSize: [14, 16], label: { normal: { show: false, backgroundColor: "#2B91B7", position: "right", color: "#ffffff", fontSize: "14", padding: 20 }, emphasis: { show: false } }, itemStyle: { normal: { color: "#11D53F", //控制图例和地图标记点的颜色 borderWidth: 2 } }, data: data_type_2 }, // 三类 { name: "三类", type: "scatter", coordinateSystem: "geo", symbol: "image://img/icon_location_3.png", symbolSize: [14, 16], label: { normal: { show: false, backgroundColor: "#2B91B7", position: "right", color: "#ffffff", fontSize: "14", padding: 20 }, emphasis: { show: false } }, itemStyle: { normal: { color: "#E39F28", borderWidth: 2 } }, data: data_type_3 } ] }; myChart.setOption(option); }); myChart.setOption(option); }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。