vue+高德封装

1.在index.html中引入js

<script type="text/javascript" src="http://webapi.amap.com/maps?v=1.4.15&key=a193b223b319b7742f1657aff8acbab0&plugin=AMap.Scale&plugin=AMap.PolyEditor&plugin=AMap.MouseTool&plugin=AMap.ControlBar&plugin=AMap.DistrictSearch"></script>

2.调用封装的js

import config from "../config/config"; // 配置项

import {loadModules} from "esri-loader";

class GDMap {

    init($el) {

        loadModules(

            [

                "esri/extras/AMapInitial",

                "esri/extras/AMapGetGrids",

                "esri/extras/AMapInitEditor",

                "dojo/parser"

            ],

            config.loadConfig

        )

            .then(

                ([

                    AMapInitial,

                    AMapGetGrids,

                    AMapInitEditor,

                    Parser

                ]) => {

                    Parser.parse(); // 解析

                    //地图初始化

                    this.ami = new AMapInitial();

                    this.ami.init_2D_map($el);

                    //获取项目区域

                    this.agg = new AMapGetGrids();

                    this.grids = this.agg.get_grids();

                    //生成项目区域,并可编辑

                    this.ame = new AMapInitEditor();

                    this.ame.init_grids_editor(this.grids);

                    this.mapStartEdit = function (type) {

                        this.ame.imit_grids_edit(type);

                    }

                }

            ) //end

            .catch((err) => {

                console.error(err);

            });

    }

}

export default GDMap

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1.在index.html中引入js 2.调用封装的js import config from "../confi...
    Rain666666阅读 335评论 0 0
  • 模板编译简介 模板编译的主要目的是将模板(template)转换为渲染函数(render) title ...
    翔子丶阅读 400评论 0 1
  • 16宿命:用概率思维提高你的胜算 以前的我是风险厌恶者,不喜欢去冒险,但是人生放弃了冒险,也就放弃了无数的可能。 ...
    yichen大刀阅读 6,122评论 0 4
  • 公元:2019年11月28日19时42分农历:二零一九年 十一月 初三日 戌时干支:己亥乙亥己巳甲戌当月节气:立冬...
    石放阅读 6,943评论 0 2