geojson 数据下载地址:https://hxkj.vip/demo/echartsMap/

可下载的数据包含省级geojson行政边界数据、市级geojson行政边界数据、区/县级geojson行政边界数据、省市区县街道行政编码四级联动数据(可精确到乡镇/街道级)

一、通过API接口,实时获取最新中国省市区县geoJSON格式地图数据,可用于Echarts地图展示

1、效果图如下


2、示例代码

 downloadMapCode() {// 下载mapCode数据let mapCode = [], cityMapCode = [], provinceMapCode = [], provinceList = [], cityList = [],districtList = [];provinceList = this.codeList.filter(item => {return item.level === 'province'})cityList = this.codeList.filter(item => {return item.level === 'city'})districtList = this.codeList.filter(item => {return item.level === 'district'})districtList.forEach(item => {mapCode.push({name: item.name,cityCode: item.code,fatherCode: `${item.code.substring(0, 4)}00`,children: []})})// 筛选出直辖市下面的区县let direct = mapCode.filter(item => {return item.fatherCode.includes('0000');})for (let i in cityList) {let children = []for (let j in mapCode) {if (mapCode[j].fatherCode == cityList[i].code) {children.push(mapCode[j])}}cityMapCode.push({name: cityList[i].name,cityCode: cityList[i].code,fatherCode: `${cityList[i].code.substring(0, 2)}0000`,children: children})}cityMapCode = cityMapCode.concat(direct);for (let i in provinceList) {let children = []for (let j in cityMapCode) {if (cityMapCode[j].fatherCode == provinceList[i].code) {children.push(cityMapCode[j])}}provinceMapCode.push({name: provinceList[i].name,cityCode: provinceList[i].code,fatherCode: '100000',children: children})}if (provinceMapCode.length === 0) returnthis.zip.file(`mapCode.json`, JSON.stringify(provinceMapCode));this.downloadTips = '文件打包压缩中...';this.zip.generateAsync({ type: "blob" }).then((content) => {saveAs(content, "mapCode.zip");});},// 下载全国地名和编码(不包含边界数据)downloadNameAndCode() {let opts = {subdistrict: 3, //返回下一级行政区showbiz: false, //最后一级返回街道信息};let district = new AMap.DistrictSearch(opts); //注意:需要使用插件同步下发功能才能这样直接使用district.search('中国', function (status, result) {if (status === 'complete') {getData(result.districtList[0]);}});let _this = thisfunction getData(data) {let districtList = data.districtList;let blob = new Blob([JSON.stringify(districtList)], {type: 'text/plain;charset=utf-8',});let filename = '全国省市区县街道和编码(不包含边界数据)';_this.$ba.trackEvent('echartsMap', '全国省市区县街道和编码(不包含边界数据)下载', filename);saveAs(blob, `${filename}.json`); //filename}},echartsMapClick(params) {//地图点击事件this.$ba.trackEvent('echartsMap', '点击地图', `${params.data.name}-${params.data.cityCode}`);if (params.data.level == 'street') return;//清除地图上所有覆盖物for (var i = 0, l = this.polygons.length; i < l; i++) {this.polygons[i].setMap(null);}this.cityName = params.data.name;this.cityCode = params.data.cityCode;this.district.setLevel(params.data.level); //行政区级别this.district.setExtensions('all');//行政区查询//按照adcode进行查询可以保证数据返回的唯一性this.district.search(this.cityCode, (status, result) => {if (status === 'complete') {this.getData(result.districtList[0], params.data.level, this.cityCode);}});},loadMapData(areaCode) {AMapUI.loadUI(['geo/DistrictExplorer'], DistrictExplorer => {//创建一个实例var districtExplorer = window.districtExplorer = new DistrictExplorer({eventSupport: true, //打开事件支持map: this.map});districtExplorer.loadAreaNode(areaCode, (error, areaNode) => {if (error) {console.error(error);return;}let mapJson = {};mapJson.type = "FeatureCollection";mapJson.features = areaNode.getSubFeatures();this.loadMap(this.cityName, mapJson);this.geoJsonData = mapJson;});});},

二、通过获取到的数据整理一系列联动数据,实现了每天自动更新

1、效果图

2、示例代码

downloadJson(nameType) {//geo文件下载this.nameType = nameTypeif (nameType === 'area') {this.$ba.trackEvent('echartsMap', '文件下载', '下载级联数据');this.$refs.dialog.show();return;}if (nameType === 'all') {this.$ba.trackEvent('echartsMap', '文件下载', '打包下载全部');this.$refs.dialog.show();return;}if (nameType === 'street') {this.$ba.trackEvent('echartsMap', '文件下载', '下载乡镇数据');this.$refs.streetDialog.show();return;}var blob = new Blob([JSON.stringify(this.geoJsonData)], { type: "text/plain;charset=utf-8" });let filename = this.cityName;if (nameType === 'code') {filename = this.cityCode;}this.$ba.trackEvent('echartsMap', '文件下载', filename);saveAs(blob, `${filename}.geoJson`);//filename},dialogConfirm() {if (this.nameType === 'area') {this.$refs.mapDataDialog.show();} else {this.downloadAllJson()}},downloadAllJson() {//一次打包下载所有的数据this.showTips();if (this.downloadTips != '下载geoJson数据') {return;}this.codeList = [];this.downloadTips = '获取数据中...';//                this.district.setLevel('country'); //行政区级别this.district.setExtensions('all');console.log('开始递归循环获取地区code..');this.loopSearch('中国');},loopSearch(code) {setTimeout(() => {this.district.search(code, (status, result) => {if (status == 'complete') {console.log(`${code}--获取成功`)for (let i in result.districtList[0].districtList) {this.codeList.push({name: result.districtList[0].districtList[i].name,code: result.districtList[0].districtList[i].adcode,level: result.districtList[0].districtList[i].level})//这边没想出来怎么判断数据是否全部加载完毕了,只能采用这种死办法//有更好解决方案的大佬,麻烦告诉我一下,邮箱t@tsy6.com//或者直接Github提交PR,在此不胜感激if (this.codeList.length >= 428) {// 为 3718 时,获取区县数据,428 省市数据console.log('code获取完成');this.isCodeListLoadComplete = true;}if (result.districtList[0].districtList[i].adcode && result.districtList[0].districtList[i].level != 'city' && result.districtList[0].districtList[i].level != 'district' && result.districtList[0].districtList[i].level != 'street') {this.loopSearch(result.districtList[0].districtList[i].adcode)}}} else {//第一遍查询出错,再次执行查询console.log(`${code}--第一次获取失败,正在尝试进行第二次获取`)this.district.search(code, (status, result) => {if (status == 'complete') {console.log(`${code}--第二次获取成功`)for (let i in result.districtList[0].districtList) {this.codeList.push({name: result.districtList[0].districtList[i].name,code: result.districtList[0].districtList[i].adcode,level: result.districtList[0].districtList[i].level})//这边没想出来怎么判断数据是否全部加载完毕了,只能采用这种死办法//有更好解决方案的大佬,麻烦告诉我一下,邮箱t@tsy6.com//或者直接Github提交PR,在此不胜感激if (this.codeList.length >= 428) {console.log('code获取完成');this.isCodeListLoadComplete = true;}}} else {console.log(`${code}--第二次获取失败,请联系email:t@tsy6.com`)}})}});}, 500)},loadAllGeoJson() {//通过codeList加载全部geoJson数据console.log('开始加载geoJson数据');AMapUI.loadUI(['geo/DistrictExplorer'], DistrictExplorer => {//创建一个实例var districtExplorer = window.districtExplorer = new DistrictExplorer({eventSupport: true, //打开事件支持map: this.map});let mapJson = {};for (let i in this.codeList) {setTimeout(() => {districtExplorer.loadAreaNode(this.codeList[i].code, (error, areaNode) => {if (error) {this.codeList[i].geo = 'error';console.log(`${this.codeList[i].name}--${this.codeList[i].code},geo 数据获取失败,高德地图的锅^_^`)} else {mapJson.type = "FeatureCollection";mapJson.features = areaNode && areaNode.getSubFeatures() || '';this.codeList[i].geo = mapJson;console.log(`${this.codeList[i].level}--${this.codeList[i].name}--${this.codeList[i].code},geo 数据获取成功,马上为你打包`)}if (this.codeList[i].level === 'province') {this.zip.file(`100000/${this.codeList[i].code}.geoJson`, JSON.stringify(mapJson));} else {this.zip.file(`100000/${this.codeList[i].code.substring(0, 2)}0000/${this.codeList[i].code}.geoJson`, JSON.stringify(mapJson));}if (this.codeList.every(item => item.geo)) {console.log('ziped');let readme = `\r\n项目源码github地址:https://github.com/TangSY/echarts-map-demo (欢迎star)\r\n个人空间:https://www.hxkj.vip (欢迎闲逛)\r\nEmail:t@tsy6.com  (遇到问题可以反馈)`;this.zip.file(`readMe(sourceCode).txt`, readme);this.downloadTips = '文件打包压缩中...';this.zip.generateAsync({ type: "blob" }).then((content) => {saveAs(content, "geoJson数据包.zip");this.downloadTips = '下载geoJson数据';this.isCodeListLoadComplete = false;this.$ba.trackEvent('echartsMap', '文件下载', '打包下载成功');});}});}, 100 * i)}});},

2022年实时最新省市区县乡镇街道geojson行政边界数据获取方法相关推荐

  1. 2022年12月最新省市区县乡镇街道geojson行政边界数据获取方法

    geojson 数据下载地址:https://geojson.hxkj.vip 可下载的数据包含省级geojson行政边界数据.市级geojson行政边界数据.区/县级geojson行政边界数据.省市 ...

  2. 实时最新中国省市区县geoJSON格式地图行政边界数据Echarts地图数据(可精确到街道级)

    geojson 数据下载地址:https://hxkj.vip/demo/echartsMap/ 可下载的数据包含省级geojson行政边界数据.市级geojson行政边界数据.区/县级geojson ...

  3. 用于ECharts的全国省市区县乡镇街道级的行政区划边界数据(GeoJSON格式)

    https://map.vanbyte.com 提供了免费的省市县3级行政边界数据(GeoJSON格式).省市县乡4级联动数据. 至于行政区划边界数据的来源,网络上有各种教程.授人以鱼不如授人以渔,下 ...

  4. 各省市乡镇街道行政边界数据获取实战

    复盘一下大佬小猿猴GISer的一个乡镇数据获取方法 主要就是QGIS+天地图这个可能是保姆级手把手教程走过路过不要错过 1.前期准备 QGIS软件+浏览器 免费啊!!免费啊!!免费啊!!免费啊!! Q ...

  5. 2022.12.5最新省市区json字符串

    [{"name": "北京市","city": [{"name": "北京市","area ...

  6. 精确到区县乡镇街道的行政边界|全国精确到街道乡镇的矢量数据 json、geojson格式

    全国精确到乡镇.街道的geojson.json数据格式,支持echarts地图数据展示 济南市长清区详细示例 全国地图截图 echarts 以北京市平谷区效果图为例 数据根据市政规划区分乡镇及街道,支 ...

  7. 2023年实时获取地图边界数据方法,省市区县多级联动【附区县乡镇街道geoJson文件下载】

    首先,来看下效果图 在线体验地址:https://geojson.hxkj.vip,并提供实时geoJson数据文件下载 可下载的数据包含省级geojson行政边界数据.市级geojson行政边界数据 ...

  8. 2023年4月实时获取地图边界数据方法,省市区县街道多级联动【附实时geoJson数据下载】

    首先,来看下效果图 在线体验地址:https://geojson.hxkj.vip,并提供实时geoJson数据文件下载 可下载的数据包含省级geojson行政边界数据.市级geojson行政边界数据 ...

  9. 2023年3月实时获取地图边界数据方法,省市区县街道多级联动【附实时geoJson数据下载】

    首先,来看下效果图 在线体验地址:https://geojson.hxkj.vip,并提供实时geoJson数据文件下载 可下载的数据包含省级geojson行政边界数据.市级geojson行政边界数据 ...

最新文章

  1. 我们能从大学里学到什么
  2. 3G时代需要“移动云计算专业”
  3. html5在线考试开发,基于HTML5的无纸化在线考试系统.docx
  4. 深度有趣 | 30 快速图像风格迁移
  5. 玩玩Xamarin Evolve 2016带来的新特性(一)-iOS Simulator(for Windows)
  6. vue的activated和deactivated生命周期
  7. 多进程event通信
  8. Facebook开源多款AI工具,支持游戏、翻译
  9. 二维数组 详解(C++)
  10. python id函数 引用本身地址_Python 之引用
  11. ModelSim 仿真教程
  12. android开发的小程序,一份基于Android平台系统下初学者开发的微信小程序的新
  13. 计算机网络三层交换机配置,综述三层交换机配置实例 附详细命令解释
  14. 说明书丨亲和纯化驴抗绵羊IgG(H+L)二抗
  15. [VS2010]逸雨清风 永久稳定音乐外链生成软件V0.1
  16. 还在搞三层架构?了解下 DDD 分层架构的三种模式吧
  17. 你喜欢哪款 Linux 桌面?萝莉风?御姐风?
  18. 解决JupyterLab或者Jupyter Notebook无法跳转到浏览器的问题
  19. 单点登录常见解决方式和阿里云短信服务
  20. 微信对账单--每日定时任务获取昨日微信支付账单

热门文章

  1. 自媒体营销方法:装修公司如何做品牌曝光和推广?
  2. js获取子节点的方法
  3. 2023年,这次动了去国企的念头!
  4. 邮箱,ip,叠词的正则处理方式
  5. html2canvas是否截图成功状态值,前端使用html2canvas截图,在canvas上绘制图片及保存图片...
  6. F12 开发人员工具入门
  7. 更改pureftpd vsftpd与proftpd的默认端口
  8. R语言-dnorm-pnorm-qnorm-rnorm的区别
  9. 程序员找工作需要关注哪些网站
  10. linux的多用户登录