echarts超级详细 手把手教你将json文件转为js文件并实现地图到市级的具体操作步骤:

下载 市地图
市地图
市地图
市地图
不是省地图!!!
没有地图的就到我的资源管理里面免费下载
所需要的的资料文件在我资源管理里面有欢迎下载使用

这个是能直接运行出地图的界面偶
在这里插入图片描述
先打开群里文件,到然后把js文件和json文件放到
在这里插入图片描述
这里面
准备工作: 1:需要你去网站上下载一个地图,下面放上连接:
传送门
然后打开地图

1:打开地图:

在这里插入图片描述

2:选择要找地区的这里以新疆某地区为例

在这里插入图片描述

3:找地区对应的json文件

假如我们需要找喀什地区地区该的地图我们要去百度的某网站下载json文件
网址
找到省
在这里插入图片描述
找到市:
在这里插入图片描述

4:找到该区域:并下载对应的json文件

在这里插入图片描述

5:打开我们项目的地图

在这里插入图片描述
可以看到我们项目中该地区的全名叫做喀什地区,所以我们在取js文件名的时候要叫做喀什地区
注意文件名一定要和我们地图上的名字一样
例如这个喀什地区对应的js文件名应该叫做喀什地区.json

6:新建一个js文件

由于这里设置了地址的位置
在这里插入图片描述
在这里插入图片描述

7:将下面代码复制到新建的js文件中

/*
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

(function(root, factory) {
    if (typeof define === 'function' && define.amd) {
        // AMD. Register as an anonymous module.
        define(['exports', 'echarts'], factory);
    } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
        // CommonJS
        factory(exports, require('echarts'));
    } else {
        // Browser globals
        factory({}, root.echarts);
    }
}(this, function(exports, echarts) {
    var log = function(msg) {
        if (typeof console !== 'undefined') {
            console && console.error && console.error(msg);
        }
    }
    if (!echarts) {
        log('ECharts is not Loaded');
        return;
    }
    if (!echarts.registerMap) {
        log('ECharts Map is not loaded')
        return;
    }
    echarts.registerMap('城市名字', "填入json里面的内容");
}));

在这里插入图片描述

8:将城市名字改成我们项目地图上的名字(这里!!! 不 加!!任何后缀)

在这里插入图片描述

9:打开json文件

在这里插入图片描述

10 将json里面的内容全部复制到"填入json里面的内容"

在这里插入图片描述
这里面,
注意
一定要把" "引号删掉, 引号删掉引号删掉!!!
这里的引号是""在这里插入图片描述
填入json里面的内容旁边的引号
在这里插入图片描述
我用的vscode安装的JSON Tools插件使用Ctrl+Alt+M会直接识别并转码让json文件正常显示
在这里插入图片描述

11修改文件名

registerMap(‘喀什地区’, 这里填入的名字
在这里插入图片描述

这里我就应该修改为
喀什地区.js
在这里插入图片描述
在这里插入图片描述
注意这里三处的名字一定一定要一样,不然就找不到不能正常显示!!!
注意这里三处的名字一定一定要一样,不然就找不到不能正常显示!!!
注意这里三处的名字一定一定要一样,不然就找不到不能正常显示!!!
都不点赞都不点赞,生气了生气了(╯▔皿▔)╯
(╯▔皿▔)╯
(╯▔皿▔)╯
(╯▔皿▔)╯
(╯▔皿▔)╯

然后保存
就可以正常显示市了
一定要让他正常显示,正常显示后再发我

都不点个赞吗看到这里了(✺ω✺)

  • 30
    点赞
  • 41
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值