├── .gitignore ├── .idea ├── misc.xml ├── modules.xml └── vcs.xml ├── .onedev-buildspec.yml ├── README.md ├── babel.config.js ├── detail.md ├── dist └── favicon.ico ├── echarts-map-demo.iml ├── package-lock.json ├── package.json ├── public ├── favicon.ico ├── index.html └── map.png ├── src ├── App.vue ├── Github.vue ├── MapRange.vue ├── MoneyDialog.vue ├── StreetDialog.vue ├── images │ ├── ad.jpg │ ├── adimg.js │ ├── alipay.png │ ├── aojiao.gif │ ├── bg_bigdata.png │ ├── data_background.png │ ├── love.jpg │ ├── pay.jpg │ └── wxpay.jpg ├── main.js ├── mapDataDialog.vue └── saveAs.js ├── vue.config.js ├── yarn.lock └── 全国省市区geoJson数据包.zip /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.onedev-buildspec.yml: -------------------------------------------------------------------------------- 1 | version: 18 2 | jobs: 3 | - name: CI/CD 4 | jobExecutor: internal 5 | steps: 6 | - !CheckoutStep 7 | name: checkout 8 | cloneCredential: !DefaultCredential {} 9 | withLfs: false 10 | withSubmodules: false 11 | condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL 12 | - !CommandStep 13 | name: build 14 | runInContainer: false 15 | interpreter: !DefaultInterpreter 16 | commands: 17 | - yarn 18 | - yarn build 19 | - '' 20 | - cd ./dist 21 | - tar -zcvf dist.tar.gz * 22 | - mv dist.tar.gz /usr/share/nginx/hxkj/dist/demo/echartsMap 23 | - cd /usr/share/nginx/hxkj/dist/demo/echartsMap/ 24 | - tar -zxvf dist.tar.gz 25 | - rm -f dist.tar.gz 26 | useTTY: false 27 | condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL 28 | triggers: 29 | - !BranchUpdateTrigger 30 | branches: master 31 | retryCondition: never 32 | maxRetries: 3 33 | retryDelay: 30 34 | cpuRequirement: 250 35 | memoryRequirement: 256 36 | timeout: 3600 37 | - name: Push to GitHub 38 | jobExecutor: internal 39 | steps: 40 | - !CheckoutStep 41 | name: checkout 42 | cloneCredential: !DefaultCredential {} 43 | withLfs: false 44 | withSubmodules: false 45 | condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL 46 | - !CommandStep 47 | name: push 48 | runInContainer: false 49 | interpreter: !DefaultInterpreter 50 | commands: 51 | - git config user.name "TangSY" 52 | - git config user.email "337828932@@qq.com" 53 | - git remote set-url origin git@@github.com:TangSY/echarts-map-demo.git 54 | - git remote -v 55 | - git push 56 | useTTY: false 57 | condition: ALL_PREVIOUS_STEPS_WERE_SUCCESSFUL 58 | triggers: 59 | - !BranchUpdateTrigger {} 60 | - !TagCreateTrigger {} 61 | retryCondition: never 62 | maxRetries: 30 63 | retryDelay: 30 64 | cpuRequirement: 250 65 | memoryRequirement: 256 66 | timeout: 3600 67 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![license](https://img.shields.io/badge/license-MIT-blue.svg) 2 | [![author](https://img.shields.io/badge/author-HashTang-orange.svg)](https://www.hxkj.vip) 3 | 4 | # echarts map 5 | 6 | 通过地图 API 获取实时最新的 geojson 数据,摆脱 geojson 文件数据过期的烦恼。 7 | 省市区县下钻。实现真正的下钻至县级,而不是只到市级。 8 | 亦可下载最新 geojson 数据。 9 | 10 | 项目介绍:[https://www.jianshu.com/p/c293c94d9ab7](https://www.jianshu.com/p/c293c94d9ab7) 11 | 12 | 体验地址:[https://geojson.hxkj.vip](https://geojson.hxkj.vip) 13 | 14 | #### 上述体验地址中可获取省市区县乡镇四级边界数据;以及四级联动或五级(村级)行政名称与编码对应关系 15 | 16 | 码云地址:[https://gitee.com/HashTang/echarts-map-demo](https://gitee.com/HashTang/echarts-map-demo) 17 | 18 | 页面效果图: 19 | 20 | ![map](https://geojson.hxkj.vip/map.png) 21 | 22 | ### 赞助 23 | 24 | [赞助二维码](https://raw.githubusercontent.com/TangSY/echarts-map-demo/master/src/images/pay.jpg) 25 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/app' 4 | ] 5 | } -------------------------------------------------------------------------------- /detail.md: -------------------------------------------------------------------------------- 1 | #####首先,来看下效果图 2 | ![map.gif](https://upload-images.jianshu.io/upload_images/7412714-3edd0e7bc2c810fa.gif?imageMogr2/auto-orient/strip) 3 | 4 | 在线体验地址:[https://hxkj.vip/demo/echartsMap/](https://hxkj.vip/demo/echartsMap/),并提供实时 geoJson 数据文件下载 5 | echarts 官方社区链接地址(可在线编辑):[https://gallery.echartsjs.com/editor.html?c=xmCAi_XNuJ](https://gallery.echartsjs.com/editor.html?c=xmCAi_XNuJ) 6 | 7 | > 前段时间给公司弄了一套基于 echarts map 的地图数据展示的平台,开发过程中发现百度官方已经不提供地图下载了,于是只能期望能在网上搜到哪位大佬帮忙收集的 json 文件。找是找到了,然鹅发现大部分都年代久远了,很多地区其实已经重新划分行政区划了。 8 | > 所以,只能想想其他办法了,回想起平常使用高德地图搜索某个地名的时候,好像会有个边界区域给我们绘制出来,然后我就觉得它既然能画出来,应该会有办法从某些渠道获取,或者高德地图会提供相应的 API。于是乎,去到了高德开放平台仔细的查看了一下他提供的 api,哈哈,果然有!有了接口,接下来就是撸码了。 9 | 10 | ####第一步,通过高德 api 获取边界数据 11 | 通过查阅 API 文档可以知道,获取边界数据的接口为行政区查询服务(`AMap.DistrictSearch`)。使用该服务之前记得去申请一个 key,用于调用高德接口,申请地址直通车:[https://lbs.amap.com/dev/key/app](https://lbs.amap.com/dev/key/app)。 12 | #####1、在页面添加 JS API 的入口脚本标签,并将其中「您申请的 key 值」替换为您刚刚申请的 key; 13 | 14 | ``` 15 | 16 | ``` 17 | 18 | #####2、通过以下方式获取数据,以获取中国地图为例; 19 | 20 | ``` 21 | this.opts = { 22 | subdistrict: 1, //返回下一级行政区 23 | showbiz: false //最后一级返回街道信息 24 | }; 25 | this.district = new AMap.DistrictSearch(this.opts);//注意:需要使用插件同步下发功能才能这样直接使用 26 | this.district.search('中国', (status, result) => { 27 | if (status == 'complete') { 28 | this.getData(result.districtList[0], '', 100000); 29 | } 30 | }); 31 | getData(data, level, adcode) {//处理获取出来的边界数据 32 | var subList = data.districtList; 33 | if (subList) { 34 | var curlevel = subList[0].level; 35 | if (curlevel === 'street') {//为了配合echarts地图区县名称显示正常,这边街道级别数据需要特殊处理 36 | let mapJsonList = this.geoJsonData.features; 37 | let mapJson = {}; 38 | for (let i in mapJsonList) { 39 | if (mapJsonList[i].properties.name == this.cityName) { 40 | mapJson.features = [].concat(mapJsonList[i]); 41 | } 42 | } 43 | this.mapData = []; 44 | //这个mapData里包含每个区域的code、名称、对应的等级,实现第三步功能时能用上 45 | this.mapData.push({name: this.cityName, value: Math.random() * 100, level: curlevel}); 46 | this.loadMap(this.cityName, mapJson); 47 | this.geoJsonData = mapJson; 48 | return; 49 | } 50 | 51 | //街道级以上的数据处理方式 52 | this.mapData = []; 53 | for (var i = 0, l = subList.length; i < l; i++) { 54 | var name = subList[i].name; 55 | var cityCode = subList[i].adcode; 56 | //这个mapData里包含每个区域的code、名称、对应的等级,实现第三步功能时能用上 57 | this.mapData.push({ 58 | name: name, 59 | value: Math.random() * 100, 60 | cityCode: cityCode, 61 | level: curlevel 62 | }); 63 | } 64 | this.loadMapData(adcode); 65 | } 66 | }, 67 | ``` 68 | 69 | #####3、接下来,利用 `AMapUI.loadUI`可以构造一个创建一个 `DistrictExplorer` 实例,然后利用 `DistrictExplorer` 的实例,可以根据当前需要加载城市的 `areaCode`获取到该城市的 `geo` 数据 70 | 71 | ``` 72 | loadMapData(areaCode) { 73 | AMapUI.loadUI(['geo/DistrictExplorer'], DistrictExplorer => { 74 | 75 | //创建一个实例 76 | var districtExplorer = window.districtExplorer = new DistrictExplorer({ 77 | eventSupport: true, //打开事件支持 78 | map: this.map 79 | }); 80 | 81 | districtExplorer.loadAreaNode(areaCode, (error, areaNode) => { 82 | 83 | if (error) { 84 | console.error(error); 85 | return; 86 | } 87 | let mapJson = {}; 88 | //特别注意这里哦,如果查看过正常的geojson文件,都会发现,文件都是以features 字段开头的,所以这里要记得加上 89 | mapJson.features = areaNode.getSubFeatures(); 90 | this.loadMap(this.cityName, mapJson); 91 | }); 92 | }); 93 | }, 94 | ``` 95 | 96 | ####第二步,用 echarts 把边界数据渲染出来 97 | 我这边使用的 echarts 版本为当前的最新版`4.2.0`,相关文档查阅地址传送门:[https://echarts.baidu.com/option.html#series-map](https://echarts.baidu.com/option.html#series-map)。千万别看错文档了,他好几个版本放在一起,关键是每个版本某些属性会不一样,所以要特别注意文档的版本与引入的 echarts 版本保持一致。 98 | #####1、在页面引入 JS 文件,我这边引入的`bootstrap cdn`提供的文件 99 | 100 | ``` 101 | 102 | ``` 103 | 104 | #####2、注册 echarts 并使用刚刚通过高德 API 获取的数据渲染成 map 105 | 106 | ``` 107 | //html 108 |
109 | 110 | //注册并赋值给echartsMap 111 | this.echartsMap = this.$echarts.init(document.getElementById('map')); 112 | 113 | //通过loadMap函数加载地图 114 | loadMap(mapName, data) { 115 | if (data) { 116 | this.$echarts.registerMap(mapName, data);//把geoJson数据注入echarts 117 | //配置echarts的option 118 | var option = { 119 | visualMap: { 120 | type: 'piecewise', 121 | pieces: [ 122 | {max: 30, label: '安全', color: '#2c9a42'}, 123 | {min: 30, max: 60, label: '警告', color: '#d08a00'}, 124 | {min: 60, label: '危险', color: '#c23c33'}, 125 | ], 126 | color: '#fff', 127 | textStyle: { 128 | color: '#fff', 129 | }, 130 | visibility: 'off' 131 | }, 132 | series: [{ 133 | name: '数据名称', 134 | type: 'map', 135 | roam: false, 136 | mapType: mapName, 137 | selectedMode: 'single', 138 | showLegendSymbol: false, 139 | visibility: 'off', 140 | itemStyle: { 141 | normal: { 142 | color: '#ccc', 143 | areaColor: '#fff', 144 | borderColor: '#fff', 145 | borderWidth: 0.5, 146 | label: { 147 | show: true, 148 | textStyle: { 149 | color: "rgb(249, 249, 249)" 150 | } 151 | } 152 | }, 153 | emphasis: { 154 | areaColor: false, 155 | borderColor: '#fff', 156 | areaStyle: { 157 | color: '#fff' 158 | }, 159 | label: { 160 | show: true, 161 | textStyle: { 162 | color: "rgb(249, 249, 249)" 163 | } 164 | } 165 | } 166 | }, 167 | data: this.mapData,//这个data里包含每个区域的code、名称、对应的等级,实现第三步功能时能用上 168 | }] 169 | }; 170 | this.echartsMap.setOption(option); 171 | } 172 | }, 173 | ``` 174 | 175 | 做完这一步,如果不出问题,中国地图已经安静的躺在你的屏幕上了! ####第三步,实现省市区县下探功能 176 | #####1、添加点击事件 177 | 178 | ``` 179 | this.echartsMap.on('click', this.echartsMapClick); 180 | 181 | echartsMapClick(params) {//地图点击事件 182 | if (params.data.level == 'street') return;//此处的params.data为this.mapData里的数据 183 | this.cityCode = params.data.cityCode; 184 | //行政区查询 185 | //按照adcode进行查询可以保证数据返回的唯一性 186 | this.district.search(this.cityCode, (status, result) => { 187 | if (status === 'complete') { 188 | this.getData(result.districtList[0], params.data.level, this.cityCode);//这个getData函数在前面已经定义过了 189 | } 190 | }); 191 | }, 192 | ``` 193 | 194 | ####此项目这边是基于`VUE`开发的,看完之后有什么不懂的,可以留言说明. 195 | 196 | 项目 GitHub 地址:https://github.com/TangSY/echarts-map-demo 197 | 198 | > 转载请注明出处:https://www.jianshu.com/p/c293c94d9ab7 199 | > 作者:TSY 200 | > 个人空间:https://www.hxkj.vip 201 | -------------------------------------------------------------------------------- /dist/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/dist/favicon.ico -------------------------------------------------------------------------------- /echarts-map-demo.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "multiple-list-demo", 3 | "version": "0.1.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "echarts": "^5.5.1", 12 | "jszip": "^3.8.0", 13 | "vue": "^2.5.17", 14 | "vue-ba": "^1.2.5" 15 | }, 16 | "devDependencies": { 17 | "@babel/preset-es2015": "^7.0.0-beta.51", 18 | "@vue/cli-plugin-babel": "^3.5.1", 19 | "@vue/cli-plugin-eslint": "^3.0.0-beta.15", 20 | "@vue/cli-service": "^3.0.0-beta.15", 21 | "babel-plugin-component": "^1.1.1", 22 | "stylus": "^0.54.5", 23 | "stylus-loader": "^3.0.2", 24 | "vue-template-compiler": "^2.5.16" 25 | }, 26 | "eslintConfig": { 27 | "root": false, 28 | "env": { 29 | "node": false 30 | }, 31 | "extends": [ 32 | "plugin:vue/essential", 33 | "eslint:recommended" 34 | ], 35 | "rules": {}, 36 | "parserOptions": { 37 | "parser": "babel-eslint" 38 | } 39 | }, 40 | "postcss": { 41 | "plugins": { 42 | "autoprefixer": {} 43 | } 44 | }, 45 | "browserslist": [ 46 | "> 1%", 47 | "last 2 versions", 48 | "not ie <= 8" 49 | ] 50 | } 51 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/public/favicon.ico -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | echarts-map最新实时geoJson文件下载_hxkj.vip_HashTang 9 | 10 | 11 | 17 |
18 | 23 | 24 | 28 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /public/map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/public/map.png -------------------------------------------------------------------------------- /src/App.vue: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 下载geoJson文件 3 | * @Author: TSY 4 | * @CreateDate: 2018/9/5 9:04 5 | * @email: t@tsy6.com 6 | */ 7 | 37 | 38 | 618 | 619 | 701 | -------------------------------------------------------------------------------- /src/Github.vue: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 右上角github入口 3 | * @Author: TSY 4 | * @Email: t@tsy6.com 5 | * @CreateDate: 2019/5/9 23:18 6 | */ 7 | 20 | 21 | 34 | 35 | -------------------------------------------------------------------------------- /src/MapRange.vue: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 3 | * @Author: TSY 4 | * @CreateDate: 2018/12/13 14:06 5 | */ 6 | 61 | 62 | 90 | 91 | -------------------------------------------------------------------------------- /src/MoneyDialog.vue: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 哎呀呀,这就是打赏弹窗,为方便你们删除,就单独抽出一个文件来吧 3 | * @Author: TSY 4 | * @Email: t@tsy6.com 5 | * @CreateDate: 2019/5/9 23:02 6 | */ 7 | 29 | 30 | 61 | 62 | -------------------------------------------------------------------------------- /src/StreetDialog.vue: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 全国乡镇数据获取 3 | * @Author: TSY 4 | * @Email: t@tsy6.com 5 | * @CreateDate: 2020/07/07 01:02 6 | */ 7 | 27 | 28 | 58 | 59 | -------------------------------------------------------------------------------- /src/images/ad.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/ad.jpg -------------------------------------------------------------------------------- /src/images/alipay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/alipay.png -------------------------------------------------------------------------------- /src/images/aojiao.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/aojiao.gif -------------------------------------------------------------------------------- /src/images/bg_bigdata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/bg_bigdata.png -------------------------------------------------------------------------------- /src/images/data_background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/data_background.png -------------------------------------------------------------------------------- /src/images/love.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/love.jpg -------------------------------------------------------------------------------- /src/images/pay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/pay.jpg -------------------------------------------------------------------------------- /src/images/wxpay.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/src/images/wxpay.jpg -------------------------------------------------------------------------------- /src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import App from './App.vue' 3 | 4 | import echarts from 'echarts' 5 | 6 | //引入百度统计插件 7 | import ba from 'vue-ba' 8 | Vue.use(ba, 'b0668f30d62e1597bdb36d05edea8960') 9 | 10 | Vue.config.productionTip = false 11 | Vue.prototype.$echarts = echarts 12 | 13 | Vue.config.productionTip = false 14 | 15 | new Vue({ 16 | render: h => h(App) 17 | }).$mount('#app') 18 | -------------------------------------------------------------------------------- /src/mapDataDialog.vue: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 全国乡镇级联数据 3 | * @Author: TSY 4 | * @Email: t@tsy6.com 5 | * @CreateDate: 2020/08/07 01:02 6 | */ 7 | 78 | 79 | 108 | 109 | -------------------------------------------------------------------------------- /src/saveAs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 保存文件到本地 3 | * @Author: TSY 4 | * @Email: t@tsy6.com 5 | * @CreateDate: 2018/12/12 23:28 6 | */ 7 | "use strict"; 8 | export default (function (view) { 9 | // IE <10 is explicitly unsupported 10 | if (typeof view === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) { 11 | return; 12 | } 13 | var doc = view.document 14 | // only get URL when necessary in case Blob.js hasn't overridden it yet 15 | , get_URL = function () { 16 | return view.URL || view.webkitURL || view; 17 | } 18 | , save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a") 19 | , can_use_save_link = "download" in save_link 20 | , click = function (node) { 21 | var event = new MouseEvent("click"); 22 | node.dispatchEvent(event); 23 | } 24 | , is_safari = /constructor/i.test(view.HTMLElement) || view.safari 25 | , is_chrome_ios = /CriOS\/[\d]+/.test(navigator.userAgent) 26 | , throw_outside = function (ex) { 27 | (view.setImmediate || view.setTimeout)(function () { 28 | throw ex; 29 | }, 0); 30 | } 31 | , force_saveable_type = "application/octet-stream" 32 | // the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to 33 | , arbitrary_revoke_timeout = 1000 * 40 // in ms 34 | , revoke = function (file) { 35 | var revoker = function () { 36 | if (typeof file === "string") { // file is an object URL 37 | get_URL().revokeObjectURL(file); 38 | } else { // file is a File 39 | file.remove(); 40 | } 41 | }; 42 | setTimeout(revoker, arbitrary_revoke_timeout); 43 | } 44 | , dispatch = function (filesaver, event_types, event) { 45 | event_types = [].concat(event_types); 46 | var i = event_types.length; 47 | while (i--) { 48 | var listener = filesaver["on" + event_types[i]]; 49 | if (typeof listener === "function") { 50 | try { 51 | listener.call(filesaver, event || filesaver); 52 | } catch (ex) { 53 | throw_outside(ex); 54 | } 55 | } 56 | } 57 | } 58 | , auto_bom = function (blob) { 59 | // prepend BOM for UTF-8 XML and text/* types (including HTML) 60 | // note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF 61 | if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) { 62 | return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type}); 63 | } 64 | return blob; 65 | } 66 | , FileSaver = function (blob, name, no_auto_bom) { 67 | if (!no_auto_bom) { 68 | blob = auto_bom(blob); 69 | } 70 | // First try a.download, then web filesystem, then object URLs 71 | var 72 | filesaver = this 73 | , type = blob.type 74 | , force = type === force_saveable_type 75 | , object_url 76 | , dispatch_all = function () { 77 | dispatch(filesaver, "writestart progress write writeend".split(" ")); 78 | } 79 | // on any filesys errors revert to saving with object URLs 80 | , fs_error = function () { 81 | if ((is_chrome_ios || (force && is_safari)) && view.FileReader) { 82 | // Safari doesn't allow downloading of blob urls 83 | var reader = new FileReader(); 84 | reader.onloadend = function () { 85 | var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;'); 86 | var popup = view.open(url, '_blank'); 87 | if (!popup) view.location.href = url; 88 | url = undefined; // release reference before dispatching 89 | filesaver.readyState = filesaver.DONE; 90 | dispatch_all(); 91 | }; 92 | reader.readAsDataURL(blob); 93 | filesaver.readyState = filesaver.INIT; 94 | return; 95 | } 96 | // don't create more object URLs than needed 97 | if (!object_url) { 98 | object_url = get_URL().createObjectURL(blob); 99 | } 100 | if (force) { 101 | view.location.href = object_url; 102 | } else { 103 | var opened = view.open(object_url, "_blank"); 104 | if (!opened) { 105 | // Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html 106 | view.location.href = object_url; 107 | } 108 | } 109 | filesaver.readyState = filesaver.DONE; 110 | dispatch_all(); 111 | revoke(object_url); 112 | } 113 | ; 114 | filesaver.readyState = filesaver.INIT; 115 | 116 | if (can_use_save_link) { 117 | object_url = get_URL().createObjectURL(blob); 118 | setTimeout(function () { 119 | save_link.href = object_url; 120 | save_link.download = name; 121 | click(save_link); 122 | dispatch_all(); 123 | revoke(object_url); 124 | filesaver.readyState = filesaver.DONE; 125 | }); 126 | return; 127 | } 128 | 129 | fs_error(); 130 | } 131 | , FS_proto = FileSaver.prototype 132 | , saveAs = function (blob, name, no_auto_bom) { 133 | return new FileSaver(blob, name || blob.name || "download", no_auto_bom); 134 | } 135 | ; 136 | // IE 10+ (native saveAs) 137 | if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) { 138 | return function (blob, name, no_auto_bom) { 139 | name = name || blob.name || "download"; 140 | 141 | if (!no_auto_bom) { 142 | blob = auto_bom(blob); 143 | } 144 | return navigator.msSaveOrOpenBlob(blob, name); 145 | }; 146 | } 147 | 148 | FS_proto.abort = function () { 149 | }; 150 | FS_proto.readyState = FS_proto.INIT = 0; 151 | FS_proto.WRITING = 1; 152 | FS_proto.DONE = 2; 153 | 154 | FS_proto.error = 155 | FS_proto.onwritestart = 156 | FS_proto.onprogress = 157 | FS_proto.onwrite = 158 | FS_proto.onabort = 159 | FS_proto.onerror = 160 | FS_proto.onwriteend = 161 | null; 162 | 163 | return saveAs; 164 | }( 165 | typeof self !== "undefined" && self 166 | || typeof window !== "undefined" && window 167 | || this.content 168 | )); 169 | -------------------------------------------------------------------------------- /vue.config.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @Description: 自定义配置 3 | * @Author: TSY 4 | * @CreateDate: 2018/6/9 13:28 5 | */ 6 | 7 | module.exports = { 8 | baseUrl: process.env.NODE_ENV === 'production' ? './' : '/', 9 | lintOnSave: false 10 | } -------------------------------------------------------------------------------- /全国省市区geoJson数据包.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TangSY/echarts-map-demo/0f39333fb199105a78e786c79a3d7119c8373b4c/全国省市区geoJson数据包.zip --------------------------------------------------------------------------------