zoukankan      html  css  js  c++  java
  • vue项目使用echarts实现区域地图绘制,且可点击单独区域

    示例图



    html:
    <div id="main" class="map"></div> js: import echarts from "echarts"; import mapJson from "../../assets/beijing_haidian.json"; let _this = this; let myChart = echarts.init(document.getElementById("main")); echarts.registerMap("高平市", mapJson, {}); // var mapJsonlen = mapJson.features.length, data = mapJson.features; var color = [ "#fecb9a", "#fefdce", "#fefa7d", "#cdccfb", "#cdf99d", "#fdcdcc" ]; var mapData = mapJson.features.map((item, index) => { return { name: item.properties.name, value: 1000, level: item.properties.level, cityCode: item.properties.adcode, itemStyle: { normal: { show: true, areaColor: color[index] || "#ddd" } } }; }); let option = { series: [ { name: "地图", type: "map", mapType: "高平市", aspectScale: 0.85, //地图长度比 itemStyle: { normal: { show: true, areaColor: "#031525" } }, label: { normal: { show: true, textStyle: { color: "#000" } } }, data: mapData } ] }; myChart.setOption(option); myChart.on("click", function(params) { _this.$router.push({ path: "/street", query: { params: params.data.name } }); console.log(params.data); });

    需要的json数据可以通过这个地址去自己下载:http://datav.aliyun.com/tools/atlas/#&lat=35.81865973449193&lng=112.96011403587735&zoom=9.5

  • 相关阅读:
    android测试开发环境搭建
    通过CMD命令行创建和使用Android 模拟器 AVD
    android 内存泄露测试
    NullPointerException检测
    iOS Automated Tests with UIAutomation
    命令方式重新签名apk
    Monkey log分析说明
    jQuery选择器总结[转]
    Java工程带库编译运行
    【转】从零开始学习Gradle之二---如何使用Task
  • 原文地址:https://www.cnblogs.com/h5it/p/14333363.html
Copyright © 2011-2022 走看看