arcgis.4x 封装

封装arcgis ,封装成链式调用方式,可以自己设置每个函数的自定义参数默认值

具体使用方式在代码注释里,后面有使用方式的demo

后期会更新代码注释以及解释的

代码


//修改 参数 1   args[0]
function editOb(a, b) {
    if (typeof b !== "object") return a;
    for (var i in b) {
        a[i] = b[i]
    }
    return a;
}
//返回一个数组
function toArray(o, is) {
    is = is === undefined ? is = 0 : is;
    var s = [];
    var i = 0;
    if (typeof o !== 'object') {
        return [o];
    }
    if (o.length !== undefined) {
        for (i = 0; i < o.length - is; i++) {
            s[i] = o[i + is];
        }
    }
    else
        each(o, function (v, k, a) {
            s[i++] = k + '|:|' + v;
            s.length = i;
        });
    return s;
}
//ajax
function ajax(ob) {
    if (!ob) throw Error("参数有误");
    var xmlhttp, type = 'get', async = true, data = {}, dataType = 'json', f = function () { }, url = '';
    if (ob.type) type = ob.type.toLocaleLowerCase();
    if (ob.async) async = ob.async;
    if (ob.data) data = ob.data;
    if (!ob.url) throw Error('参数url属性有误');
    if (ob.dataType) dataType = ob.dataType;
    if (ob.success) f = ob.success;
    url = ob.url;
    if (typeof data == 'object') {
        var str = '';
        for (var i in data) {
            if (!str) str += '?' + i + '=' + data[i];
            else str != '&' + i + '=' + data[i];
        }
        data = str;
        if (type == 'post') data = data.substr(1);
        if (url.indexOf('?') >= 0) data = '&' + data.substr(1);

    }
    if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp = new XMLHttpRequest();
    }
    else {// code for IE6, IE5
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    if (!xmlhttp) {
        throw Error("此浏览器不支持AJAX");
    }

    switch (type) {
        case 'get':
            xmlhttp.open(type, url + data, async);
            xmlhttp.send();
            break;
        case 'post':
            xmlhttp.open(type, url, async);
            xmlhttp.send(data);
            break;
        default:
            throw Error("参数type属性有误");
    }
    xmlhttp.onreadystatechange = function () {
        if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
            switch (dataType) {
                case "json":
                    try { f(JSON.parse(xmlhttp.response)) }
                    catch (e) {
                        try {
                            f(eval(xmlhttp.response));
                        }
                        catch (e) {
                            f(xmlhttp.response);
                        }                      
                    };
                    break;
                case "text": f(xmlhttp.response);
                    break;
                default:
                    f(xmlhttp.response);
            }

        }
    }
    return xmlhttp;
}
//返回对象的构造器名字
function typeClass(val) {
    return Object.prototype.toString.call(val).split(' ')[1].slice(0, -1);
}
//复制一个obj 返回复制品
function newObj(_obj) {
    var a = {};
    for (var i in _obj) a[i] = _obj[i];
    return a;
}
//返回新的obj
function editObNew(a, b) {
    a = newObj(a);
    if (typeof b !== "object") return a;
    for (var i in b) {
        a[i] = b[i]
    }
    return a;
}
function bindArg(a, b) {
    var arg = toArray(arguments, 2)
    if (!b) b = function () { return toArray(arguments); };
    return function () {
        var _arg = [].concat(arg).concat(toArray(arguments));
        return a.apply(this, b.apply(this, _arg));
    }
}

function replace(original, replace, val) {
    if (arguments.length < 2) throw Error('参数数量不对');
    if (typeof original !== "string" && typeof original !== "object") throw TypeError('arg【0】参数类型错误');
    if (typeof replace !== "string" && typeof replace !== "number") throw TypeError('arg【1】参数类型错误');
    if (typeof original === "string")
        return original.split(replace).join(val);
    return original.map(function (v, k) { if (replace !== "string" && replace == k) return val; else if (replace !== "number" && replace === v) return val; else return v; })
}

function filter(arr, fs, t) {
    var a = [], i = 0, j = 0, is = false;
    if (t == null) t = this;
    if (Array.prototype.filter) {
        return Array.prototype.filter.call(arr, fs);
    }
    while (arr[i]) {
        is = fs.call(t, arr[i], i, arr);
        if (is) {
            a[j++] = arr[i];
        }
        i++;
    }
    return a;
}
function detection(ob, o) {
    if (!ob) {
        return false;
    }
    for (var k in o) {
        if (o[k] == ob[k]) return true;
    }
    return false;
}
//each循环
function each(arr, f) {
    if (typeof arr !== 'object' || typeof f !== "function") throw TypeError("参数错误");
    for (var i in arr) if (f.call(arr[i], arr[i], i, arr)) return arr;
    return arr;
}
///注释 有不理解的 看代码 .....
//arcgis 4.X 封装    arg【0】 key 需要导入的模块   value 给导入模块设置默认值
//arcgisModel4X(id) id为字符串  此方法会返回一个 加载好的esri模块  注!!!! 此模块为异步加载的  所有模块加载完或 执行  acgisModel4X.onLoadEnd方法
//arcgisModel4X 属性及方法介绍 
// require 跟dojo 一样  不过 参数仅为一个     object 类型 key为 导入模块的字符串 value为 默认值 通过此方法导入的模块 会被所有 Esri实例所继承 

//Esri类  说明  arcgisModel4X (id)会生成一个 esri实例 


//Esri 继承属性介绍
var arcgisModel4X = (function (req, tooReq) {
    //ESRI 缓存变量
    var ids = {}, fs = {}, reqLoadCounts = 0, reqLoad = {}, reqCounts = 0, getCustomData = {};
    //TOOl 缓存变量
    var too = {};
    var tooArr = ["esri/core/watchUtils", "esri/geometry/Point", "esri/geometry/geometryEngine", "esri/symbols/PictureMarkerSymbol", "esri/symbols/TextSymbol", "esri/Color", "esri/symbols/Font", "esri/symbols/SimpleLineSymbol", "esri/geometry/Polygon", "esri/symbols/SimpleFillSymbol"];
    reqCounts += tooArr.length, reqCounts+= Object.keys(req).length;
    require(tooArr, function () {
        var i = 0;
        while (arguments[i]) {
            var stName = tooArr[i].split('/')[tooArr[i].split('/').length - 1];
            too[stName] = arguments[i];
            if (fs[stName] === undefined);
            fs[stName] = arguments[i];
            i++;
        }
        reqLoadCounts += tooArr.length;
        if (reqLoadCounts === reqCounts && main.onLoadEnd) main.onLoadEnd(),main.onLoadEnd=null;
    })
    each(req, function (v, k, o) {
        var as = k.split('/')[k.split('/').length - 1];
        require([k], function (a) {
            console.log(as + '模块加载完毕');
            reqLoadCounts++;
            reqLoad[k] = v;
            fs[as] = a;
            if (this.$reqLoadFs) this.$reqLoadFs.call(this, a, v);
            if (reqLoadCounts === reqCounts && main.onLoadEnd) main.onLoadEnd(),main.onLoadEnd = null;
        });

    })
    _require = function (url, fs) {
        require([url]);
        try {
            return require(url);
        } catch (e) {
            require([url], fs);
        }
    }
    main.require = function (ob, _fs) {

        each(ob, function (v, k, o) {
            var as = k.split('/')[k.split('/').length - 1];
            if (!(as in fs)) reqCounts++, reqLoadCounts++;
            var a, ret;
            try {
                a = require(k);
                console.log(as + '模块加载完毕');
                reqLoad[k] = v;
                fs[as] = a;
                Esri.prototype[as] = (function () {
                    var cs = as, req = v;
                    return function (_ob) {
                        var ob = editOb({}, v); editOb(ob, _ob);
                        var fs = ob.$customEzFs;
                        if (!ob.$customEzFs) fs = function (fs, ob) { return fs(ob); }
                        var rt = fs.call(this, a, ob);
                        this[cs]['$' + cs] = rt;
                        this[0] = rt;
                        return this;
                    }
                })();
                if (this.$reqLoadFs) this.$reqLoadFs.call(this, a, v);
                else a(ob);
                if (typeof _fs === "function") return _fs(ob);
                return a;
            } catch (e) {
                require([k], function (a) {
                    if (a === undefined) throw Error(as + "此模块加载失败.");
                    console.log(as + '模块加载完毕');
                    reqLoad[k] = v;
                    fs[as] = a;
                    Esri.prototype[as] = (function () {
                        var cs = as, req = v;
                        return function (_ob) {
                            var ob = editOb({}, v); editOb(ob, _ob);
                            var fs = ob.$customEzFs;
                            if (!ob.$customEzFs) fs = function (fs, ob) { return fs(ob); }
                            var rt = fs.call(this, a, ob);
                            this[cs]['$' + cs] = rt;
                            this[0] = rt;
                            return this;
                        }
                    })();
                    if (this.$reqLoadFs) this.$reqLoadFs.call(this, a, v);
                    else a(ob);
                    if (typeof _fs === "function") return _fs(ob);
                })

            }
            return function (s) {
                var tfs = fs[as], mod = k, vl = editObNew({}, v);
                if (!tfs) return tfs;
                require([mod], function (F) {
                    if (F === undefined) throw Error("模块地址填写错误.");
                    s.call(vl, F, vl, k);
                })
            }
        })
    }
    main.onLoadEnd = function () {

    }
    main.esriFs = fs;
    main.removeGraphic = function (graphic, fs) {
        var i = 0, graphics = [];
        if (typeof (fs) !== "function") fs = function () { return false };
        if (graphic.graphics && graphic.graphics.items) {
            graphics = graphic.graphics.items;
        } else if (typeof (graphic) === "string") {
            graphics = this.getMapLayer(graphic);
            if (graphic && !graphic.length) return;
            graphics = graphics.graphics.items;
        }
        else if (graphic.length <= 0) {
            graphics = graphic
        } else if (typeof (graphic) === "object") {
            graphics = [graphic];
        }
        while (graphics[i]) {
            if (fs(graphics[i])) {
                graphics[i].layer.graphics.remove(graphics[i]);
                i--;
            }
            i++;
        }
        return graphics;
    }
    main.remove = function (id) {
        if (id in ids) {
            delete ids[id];
            console.log(id + "删除成功");
            return 1;
        }
        return 0;
    }
    main.getIds = function () {
        var arr = [];
        for (var i in ids) {
            arr.push(i);
        }
        return arr;
    }
    main.calculateGeometry = function (graphics, units, digits, digitsName) {
        var spatialReference = graphics.geometry.spatialReference;
        if (units && digits) digitsName = "";
        if (typeof (units) != "number") units = 1000;
        if (typeof (digits) != "number") digits = 2;
        if (typeof (digitsName) != "string") digitsName = "公里";
        if (!graphics) return [];
        var graphicList = [];
        var graphic = graphics[0] || graphics;
        switch (graphic.geometry.type) {
            case "polyline": polylineShow(graphic); break;
            case "polygon": areaShow(graphic); break;
            case "circle": break;
        }

        showRest(graphics)
        function polylineShow(graphic) {

            var les = arcgisModel4X.measureGeometry(graphic.geometry)
            var val = les.length;
            var i = 0;
            var center =new fs.Point(les.line[i].X, les.line[i].Y, spatialReference);

            var textSymbol = fs.TextSymbol({
                //  type: "text",  // autocasts as new TextSymbol()
                color: "red",
                haloColor: "black",
                haloSize: "1px",
                text: "起点",
                xoffset: 3,
                yoffset: 3,

                font: {  // autocast as new Font()
                    size: 15,
                   
                 
                }
            });
            graphicList.push(new fs.Graphic({ geometry: center, symbol: textSymbol, attributes: { id: graphic.uid } }));
            while (les.every[i]) {
                var leKm = les.every[i];
                var x = les.line[i + 1].X;
                var y = les.line[i + 1].Y;              
                leKm = (leKm / units).toFixed(digits) + digitsName;
                var textSymbol = fs.TextSymbol({
                    //  type: "text",  // autocasts as new TextSymbol()
                    color: "white",
                    haloColor: "black",
                    haloSize: "1px",
                    text: leKm,
                    xoffset: 3,
                    yoffset: 3,

                    font: {  // autocast as new Font()
                        size: 15,
                       
                     
                    }
                });
                var center =new fs.Point(x, y, spatialReference);
                graphicList.push(new fs.Graphic({ geometry: center, symbol: textSymbol, attributes: { id: graphic.uid } }));
                i++;
            }

        }
        function areaShow(graphic) {
            if (digitsName && digitsName.indexOf("平方")<0) digitsName = "平方" + digitsName;
            var center = graphic.geometry.centroid;
            var val = arcgisModel4X.measureGeometry(graphic.geometry);
            val = Math.abs(val);
            val = (val / (units * units)).toFixed(digits) + digitsName;
            var textSymbol = fs.TextSymbol({
                //  type: "text",  // autocasts as new TextSymbol()
                color: "white",
                haloColor: "black",
                haloSize: "1px",
                text: val,
                xoffset: 3,
                yoffset: 3,

                font: {  // autocast as new Font()
                    size: 15,
                   
                 
                }
            });

            graphicList.push(new fs.Graphic({ geometry: center, symbol: textSymbol, attributes: { id: graphic.uid } }));
        }
        function circleShow(geometry) {

        }
        function showRest(graphic) {
        }
        return graphicList;
    }
    main.getCustomData = function (name) {
        return getCustomData[name];
    }
    main.setCustomData = function (name, value) {
        getCustomData[name] = value;
        return getCustomData[name];
    }
    main.measureGeometry = function (geometry) {
        switch (geometry.type) {
            case "polygon": return __MeasureGeometry(geometry); break;
            case "polyline": return __MeasureGeometry(geometry); break;
        }
        function __MeasureGeometry(geometry) {
            //打开图形事件
            //tempGraphicLayer.enableMouseEvents();
            ifJuli = false;
            var points = [];
            var isDegree = true;

            if (geometry.type == "polygon") {
                var pointsArr = geometry.rings[0];
                for (var i = 0; i < pointsArr.length; i++) {
                    var x = pointsArr[i][0];
                    var y = pointsArr[i][1];
                    if (x > 360 || y > 360 || x < -360 || y < -360) isDegree = false;
                    points.push({ X: x, Y: y });
                }
                var area = __MeasurePolygonArea(points, isDegree);
                var areaInfo = "";
                areaInfo = parseInt(area / 100) * 100 
                return areaInfo;

                //if (noty) noty({ text: areaInfo, type: "information", layout: "center" }).setTimeout(5000);
                // else alert(areaInfo);
            }
            else if (geometry.type == "polyline") {

                var pointsArr = geometry.paths[0];
                for (var i = 0; i < pointsArr.length; i++) {
                    var x = pointsArr[i][0];
                    var y = pointsArr[i][1];
                    if (x > 360 || y > 360 || x < -360 || y < -360) isDegree = false;
                    points.push({ X: x, Y: y });
                }
                var length = __MeasureLineLength(points, isDegree);
                var lengthInfo = "";
                length.length = lengthInfo;
                return length
            }
        }
        /// <summary>
        /// 计算点对象构成的多边形长度(多边形不能自交,如果自交返回 -1)。
        /// </summary>
        /// <param name="points">点。</param>
        /// <param name="isDegree">是否为极坐标系。</param>
        /// <returns>返回多边形的面积,如果自交返回 -1。</returns>
        function __MeasureLineLength(points, isDegree) {
            var line = points;
            var lengths = [];
            if (line.length < 2) return -1;

            var length = 0;
            var offX;
            var offY;

            for (var i = 0; i < line.length - 1; i++) {
                var _le = 0;
                offX = line[i].X - line[i + 1].X;
                offY = line[i].Y - line[i + 1].Y;

                if (isDegree) _le = __DistanceOfDegreeTwoPoints(line[i].Y, line[i].X, line[i + 1].Y, line[i + 1].X);   // 极座标点的距离计算
                else _le = Math.sqrt(offX * offX + offY * offY);// 平面坐标系点的距离计算               
                length = _le + length;
                lengths.push(length);
            }

            return { sum: length, every: lengths, line: line };
        }

        function __DistanceOfDegreeTwoPoints(lat1, lng1, lat2, lng2) {
            var radLat1 = lat1 * Math.PI / 180;
            var radLat2 = lat2 * Math.PI / 180;
            var a = radLat1 - radLat2;
            var b = lng1 * Math.PI / 180 - lng2 * Math.PI / 180;
            var s = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(a / 2), 2) + Math.cos(radLat1) * Math.cos(radLat2) * Math.pow(Math.sin(b / 2), 2)));
            s = s * 6378137;
            s = Math.round(s * 10000) / 10000;
            return s;
        }

        /// <summary>
        /// 计算点对象构成的多边形面积(多边形不能自交,如果自交返回 -1)。
        /// </summary>
        /// <param name="points">点。</param>
        /// <param name="isDegree">是否为极坐标系。</param>
        /// <returns>返回多边形的面积,如果自交返回 -1。</returns>
        function __MeasurePolygonArea(points, isDegree) {
            var polygon = points;

            // 如果不是规则的多面(自交),则返回面积为 -1
            if (__PolygonIsIntersect(polygon)) {
                //alert(points.CheckStandardErrorInfo);
                return -1;
            }

            if (isDegree) return __MeasureDegreePolygonArea(points);

            var area = 0;
            var len = polygon.length;
            var j = 0;

            for (var i = 0; i < len; i++) {
                j = (i + 1) % len;
                area += polygon[i].X * polygon[j].Y;
                area -= polygon[i].Y * polygon[j].X;
            }

            area /= 2;

            return (area < 0 ? -area : area);
        }
        /// <summary>
        /// 判断一个面是否自交。
        /// </summary>
        /// <param name="points">面中的点集合。</param>
        /// <returns>自交返回true,否则返回false。</returns>
        function __PolygonIsIntersect(points) {

            // 不能封闭图形
            if (points.length < 3) {
                alert("\npoints.length<3\n");
                return true;
            }

            // 三角形合法
            if (points.length < 4) return false;

            // 判断当前图形是否合法(不可以为一个多孔的面)
            for (var i = 0; i < points.length - 1; i++) {
                for (var j = i + 1; j < points.length; j++) {
                    if (j == (points.length - 1)) {
                        if (__LineIsIntersect(points[i].X, points[i].Y, points[i + 1].X, points[i + 1].Y, points[j].X, points[j].Y, points[0].X, points[0].Y)) {
                            return true;
                        }
                    }
                    else {
                        if (__LineIsIntersect(points[i].X, points[i].Y, points[i + 1].X, points[i + 1].Y, points[j].X, points[j].Y, points[j + 1].X, points[j + 1].Y)) {
                            return true;
                        }
                    }

                }
            }

            return false;
        }

        // 极坐标距离计算
        function __MeasureDegreePolygonArea(points) {
            var area = 0;

            if (points.length > 2) {
                var p1, p2;
                for (var i = 0; i < points.length - 1; i++) {
                    p1 = points[i];
                    p2 = points[i + 1];
                    area += __rad(p2.X - p1.X) * (2 + Math.sin(__rad(p1.Y)) + Math.sin(__rad(p2.Y)));
                }

                area = area * 6378137 * 6378137 / 2;
            }

            return area;
        }
        /// <summary>
        /// 判断两条线是否相交
        /// </summary>
        /// <param name="x1">线中一个端点的X坐标。</param>
        /// <param name="y1">线中一个端点的Y坐标。</param>
        /// <param name="x2">线中一个另端点的X坐标。</param>
        /// <param name="y2">线中一个另端点的Y坐标。</param>
        /// <param name="x3">另一条线中一个端点的X坐标。</param>
        /// <param name="y3">另一条线中一个端点的Y坐标。</param>
        /// <param name="x4">另一条线中另一个端点的X坐标。</param>
        /// <param name="y4">另一条线中另一个端点的Y坐标。</param>
        /// <returns>相交返回true,否则返回false。</returns>
        function __LineIsIntersect(x1, y1, x2, y2, x3, y3, x4, y4) {

            // 优先考虑最大外截矩形是否相交
            if (x3 > Math.max(x1, x2) && x3 < Math.min(x1, x2) && x4 > Math.max(x1, x2) && x4 < Math.min(x1, x2) && y3 > Math.max(y1, y2) && y3 < Math.min(y1, y2) && y4 > Math.max(y1, y2) && x4 < Math.min(y1, y2)) {
                return false;
            }


            // 是否平行y轴
            if (x1 == x2 && x3 != x4) {
                var k2 = (y3 - y4) / (x3 - x4);
                var c = y3 - k2 * x3;
                var y = k2 * x1 + c;
                if (y > Math.min(y1, y2) && y < Math.max(y1, y2) && y > Math.min(y3, y4) && y < Math.max(y3, y4)) {
                    return true;
                }
                else {
                    return false;
                }
            }
            if (x1 != x2 && x3 == x4) {
                var k1 = (y1 - y2) / (x1 - x2);
                var b = y1 - k1 * x1;
                var y = k1 * x3 + b;
                if (y > Math.min(y1, y2) && y < Math.max(y1, y2) && y > Math.min(y3, y4) && y < Math.max(y3, y4)) {
                    return true;
                }
                else {
                    return false;
                }
            }
            if (x1 == x2 && x3 == x4) {
                return false;
            }



            // 两条线是否平行
            var k1 = (y1 - y2) / (x1 - x2);
            var k2 = (y3 - y4) / (x3 - x4);
            if (k1 == k2) return false;


            // 普通线段
            var b = y1 - k1 * x1;
            var c = y3 - k2 * x3;
            var y = ((k2 * b) - (k1 * c)) / (k2 - k1);
            var minx = 0.00001;
            if (y >= Math.min(y1, y2) + minx && y <= Math.max(y1, y2) - minx && y >= Math.min(y3, y4) + minx && y <= Math.max(y3, y4) - minx) {
                return true; // 交点在两条线上
            }

            return false;

        }
        function __rad(_) {
            return _ * Math.PI / 180;
        }

    }

    function entrust(obj, obj2) {
        return [editObNew(obj, obj2)];
    }

    function main(id) {
        if (id in ids) return ids[id];
        ids[id] = new Esri(id);

        return ids[id];
    }
    function RValue() {

    }
    //ESRI Calss 继承类
    Esri.prototype.tools = too;
    Esri.prototype.removeMapLayer = function (id) {
        var str = "", i = 0, arr = this.getPresentUseMap.layers.items, map = this.getPresentUseMap;
        while (arr[i]) {
            if (arr[i].id === id) {
                console.log("删除成功");
                str = id;
                map.layers.remove(arr[i]);
                break;
            } i++;
        }
        this.getPresentUseLayers = this.getPresentUseMap.layers.items;
        if (!str) console.log("不存在该id的底图" + id);
        return this;
    }
    Esri.prototype.addMapLayer = function (layer) {
        var i = 0, is = false, titleLayer, ob = this.$mapLayers; var ob2;
        if (this.getPresentUseMap && this.getPresentUseMap.layers) {
            ob2 = this.getPresentUseMap.layers;
        }
        while (ob[i]) {
            if (ob[i].id === layer.id) {
                console.warn("已存在id为" + layer.id + "的底图");
                //return this;
                break;
            }
            i++;
        }
        if (i == ob.length ) {
            console.warn("添加成功id" + layer.id + "的底图");
            if (layer.type === "tile") {
                ob.unshift(layer);
            } else {
                ob.push(layer);
            }
        }

        if (ob2) {
            i = 0
            while (ob2.items[i]) {
                if (ob2.items[i].id === layer.id) {
                    i = -1
                    return this;
                }
                i++;
            }
            if (i >= 0) {
                if (layer.type === "tile") {
                    ob2.unshift(layer);
                } else {
                    ob2.add(layer);
                }
            }
               
        }
        return this;
    }
    Esri.prototype.getMapLayer = function (id) {
        if (this.getPresentUseMap.layers == undefined) return [];
        var i = 0, arr = this.getPresentUseMap.layers.items;

        while (arr[i]) {
            if (arr[i].id === id) {
                return arr[i];
            }
            i++;
        }
        if (id !== undefined) return null;
        return arr;
    }
    Esri.prototype.removeMapLayerAll = function () {
        this.$mapLayers = [];
    }
    Esri.prototype.getEsriData = function (str, ob) {
        if (!this[str]) throw Error('参数有误');
        var data = this[str]['$' + str] || {}, i = 0;
        while (data[i]) {
            if (detection(data[i], ob)) return data[i];
            i++;
        }
        if (ob) return false;
        return data;
    }
    Esri.prototype.filterEsriData = function (cs, fs, t) {
        var data = this['$' + cs];
        this['$' + cs] = filter(data, fs, t);
    }
    Esri.prototype.removeEsriData = function (cs, ob) {
        if (this[cs] == undefined) throw Error("args[0]参数有误");
        var data = this[cs]['$' + cs], i = 0, o = {}, a = [], j = 0, is = false;
        if (data.length == null || data.length == undefined) {
            if (detection(data[i], ob)) {
                delete this[cs]['$' + cs];
                console.error("已删除" + '$' + cs);
                return true;
            }
            console.error("删除失败" + '$' + cs);
            return false;
        }
        while (data[i]) {
            o = data[i];
            if (!detection(o, ob)) {
                a[j++] = o;
            }
            i++;
        }
        this[cs]['$' + cs] = a;
        return true;
    }
    Esri.prototype.esriClassFunction = editOb({}, fs);
    Esri.prototype.require = function (str, fs) {
        require(str, function (FS, ts) {
            fs(FS, ts);
        })
    }
    Esri.prototype.getGraphic = function (fs, layer) {
        if (!fs) fs = function () { return true };
        if (typeof (layer) === "string"||layer==undefined) layer = this.getMapLayer(layer);
        var i = 0, graphics = [];
        if (typeof (fs) !== "function" && fs){
            var o=fs; 
            fs = function (g) {
                if (g.attributes === o || g.uid === o || g.id === o, detection(g.attributes, o) || detection(g, o)) {
                    return true;
                }
            }
        }
        if (layer && layer.length == undefined) layer = [layer];
        if (!layer||!fs) return [];
        while (layer[i]) {
            var j = 0;
            var _graphics =layer[i].graphics==undefined?[]: layer[i].graphics.items;
            while (_graphics[j]) {
                if (fs(_graphics[j])) {
                    graphics.push(_graphics[j])
                }
                j++;
            }
            i++;
        }
        return graphics;
    }
    Esri.prototype.removeGraphic = function (fs, graphic) {
        var i = 0, graphics = [],layers=[],j=0;
        if (typeof (fs) !== "function" && fs) {
            var o = fs;
            fs = function (g) {
                if (g.attributes === o || g.uid === o || g.id === o, detection(g.attributes, o) || detection(g, o)) {
                    return true;
                }
            }
        }
          if (typeof (graphic) === "string" || graphic==undefined) {
                    layers = this.getMapLayer(graphic);
                    if (!layers) return this;
                    if (!layers.length) graphics = layers.graphics.items
         } else if (graphic.graphics && graphic.graphics.items) {
             graphics = graphic.graphics.items;
         }
         else if (graphic.length <= 0) {
            graphics = graphic
        }
          if (!fs || !graphics) return this;
          if (!layers.length || layers.length <= 0) {
              layers = [{ graphics: { items: graphics } }]
          }
          while (layers[j]) {
              i = 0;
              graphics =layers[j].graphics==undefined?[]: layers[j].graphics.items;
              while (graphics[i]) {

                  if (fs(graphics[i])) {
                      graphics[i].layer.graphics.remove(graphics[i]);
                      i--;
                  }
                  i++;
              }
              j++;
          }

        return this;
    }
    Esri.prototype.removeAllGraphic = function (layer) {
        if (typeof (layer) === "string") layer = this.getMapLayer(layer);
        if (layer&&typeof(layer.removeAll) === "function") layer.removeAll();
        return this;
    }
    Esri.prototype.goToView = function (ob, ob2, ob3) {
        var point;
        if (!ob) return this;
        if (typeof (ob) === "object" && typeof (ob2) === "object" && (ob.constructor == ob2.constructor || (ob.x && ob.y && (ob2.popupTemplate || (ob2.length && ob2[0].popupTemplate))))) {
            this.getPresentUseView.goTo(ob);
            point = ob.geometry || ob;
            if (ob2.constructor!==Array) {
                ob2 = [ob2];
            }
            this.getPresentUseView.popup.open({ location: point, features: ob2 })
        }
        else if (typeof (ob) === "object")
            this.getPresentUseView.goTo(ob);
        else if (ob && ob2 && (typeof (ob) === "string" || typeof (ob) === "number")) {
            point = this.tools.Point({ x: ob, y: ob2, z: ob3 ,spatialReference:this.getPresentUseView.spatialReference});
            this.getPresentUseView.goTo(point);
        }
        return this;
    }
    Esri.prototype.refreshGraphicLayer = function () {
        var layers = this.getMapLayer(), i = 0;
        while (layers[i]) {
            if (layers[i].graphics && layers[i].graphics.length)
                layers[i].graphics.removeAll();
            if (typeof (layers[i].refresh) === "function")
                layers[i].refresh();
            i++;
        }
        return this;
    }
    Esri.prototype.showGeometry = function (graphics) {
        this.removeGraphic(graphics.layer, function (g) { if (g.attributes && (g.attributes.id == graphics.uid)) return true; })
        var graphic = graphics[0] || graphics;
        switch (graphic.geometry.type) {
            case "polyline": polylineShow(graphic); break;
            case "polygon": areaShow(graphic); break;
            case "circle": break;
                return this;
        }

        showRest(graphics)
        function polylineShow(graphic) {

            var les = arcgisModel4X.measureGeometry(graphic.geometry)
            var val = les.length;
            var i = 0;
            var center = this.tools.Point(les.line[i].X, les.line[i].Y, 4326);

            var textSymbol = this.tools.TextSymbol({
                //  type: "text",  // autocasts as new TextSymbol()
                color: "red",
                haloColor: "black",
                haloSize: "1px",
                text: "起点",
                xoffset: 3,
                yoffset: 3,

                font: {  // autocast as new Font()
                    size: 15,
                   
                 
                }
            });
            this.Graphic({ geometry: center, symbol: textSymbol, $layer: graphic.layer, attributes: { id: graphic.uid } })
            while (les.every[i]) {
                var leKm = les.every[i];
                var x = les.line[i + 1].X;
                var y = les.line[i + 1].Y;
                var textSymbol = this.tools.TextSymbol({
                    //  type: "text",  // autocasts as new TextSymbol()
                    color: "white",
                    haloColor: "black",
                    haloSize: "1px",
                    text: leKm,
                    xoffset: 3,
                    yoffset: 3,

                    font: {  // autocast as new Font()
                        size: 15,
                                           
                    }
                });
                var center = this.tools.Point(x, y, 4326);
                this.Graphic({ geometry: center, symbol: textSymbol, $layer: graphic.layer, attributes: { id: graphic.uid } })
                i++;
            }

        }
        function areaShow(graphic) {

            var center = graphic.geometry.centroid;
            var val = arcgisModel4X.measureGeometry(graphic.geometry);
            var textSymbol = this.tools.TextSymbol({
                //  type: "text",  // autocasts as new TextSymbol()
                color: "white",
                haloColor: "black",
                haloSize: "1px",
                text: val,
                xoffset: 3,
                yoffset: 3,

                font: {  // autocast as new Font()
                    size: 15,
                }
            });
            this.Graphic({ geometry: center, symbol: textSymbol, $layer: graphic.layer, attributes: { id: graphic.uid } })

        }
        function circleShow(geometry) {

        }
        function showRest(graphic) {
        }
        return this;
    }
    function Esri(id) {
        this.id = id;
        var _esri = this;
        this.getPresentUseView = {};
        this.getPresentUseMap = {};
        this.getPresentUseLayers = [];
        this.$GraphicsLayers = [];
        this.$mapLayers = [];
        var esriMain = this;
        var esriData = {};
        var req = tooReq;
        this.viewOn = function (ob) {
            if (!esriData.viewOn) esriData.viewOn = {};
            if (!ob) {return this }
            var id, name, fs,on;
            if(arguments.length>2){
                id=arguments[0], name=arguments[1], fs=arguments[2];
            } else if (arguments.length == 2) {
               name = arguments[0], fs = arguments[1];
            } else if (arguments.length == 1 && typeof (ob) == "object") {
                id = ob["id"], name = ob["name"], fs = ob["fs"];
            } else {
                return esriData.viewOn[ob];
            }           
            if (!id) {
                var _fs = fs;
                fs = function (e) { _fs(e); on.remove(); }             
            }
            on = this.getPresentUseView.on(name, fs);
            if (id) esriData.viewOn[id] = on;
            return this;
        }
        this.getCustomData = function (name) {
            if (esriData.getCustomData === undefined) esriData.getCustomData = {};
            return esriData.getCustomData[name];
        }
        this.setCustomData = function (name, value) {
            if (esriData.getCustomData === undefined) esriData.getCustomData = {};
            esriData.getCustomData[name] = value;
            return this;
        }
        this.setEsriData = function (key, value, str) {
            var i = 0;
            if (!key || !value) {
                return this;
            }
            var oo;
            if (str) {
                if (typeof (str) == "string") oo = { str: value[str] }; else oo = str;
                if (esriData[key] && esriData[key][i]) {
                    while (esriData[key][i]) {
                        if (detection(esriData[key][i], oo))
                            return this;
                        i++;
                    }
                } else {
                    if (detection(esriData[key], oo))
                        return this;
                }
            }
            if (esriData[key] == undefined) {
                esriData[key] = value;
            } else if (typeof (esriData[key].push) === "function") {
                esriData[key].push(value)
            } else {
                esriData[key] = value;
            }
            return this;
        }
        this.getEsriData = function (str, ob) {
            if (!esriData[str]) { console.warn('参数有误'); return false; }
            var data = esriData[str] || {}, i = 0;
            while (data[i]) {
                if (detection(data[i], ob)) return data[i];
                i++;
            }
            if (ob) return false;
            return data;
        }
        this.watchUtils;
        this.changeLayer = function (fs) {
            var layers = _esri.getPresentUseMap.layers.items, i = 0;
            if (typeof (fs) !== "function") {
                return this;
            }

            while (layers[i]) {
                fs(layers[i]);
                if (typeof (layers[i].refresh) === "function")
                    layers[i].refresh();
                i++;
            }
            return this;
        }
        this.geometrySing = function (str) {
            var sket = _esri.getEsriData("Sketch");
            switch (str) {
                case "polyline": sket.create("polyline"); break;
                case "polygon": sket.create("polygon"); break;
                case "rectangle": sket.create("rectangle"); break;
                case "circle": sket.create("circle"); break;
                case "removeAll": sket.layer.removeAll(); break;
            }
        }
        this.overviewMapDijit = function (ob) {
            var pdm = this.getPresentUseView.container;
            ob = editObNew(tooReq.overviewMapDijit, ob);
            var mapView = ob.view;
            var mainView = this.getPresentUseView;
            var watchUtils = too.watchUtils || require("esri/core/watchUtils")
            var Point = too.Point || require("esri/geometry/Point")
            if (!mapView) {
                var overviewDiv = document.createElement("div");
                var eventDiv = document.createElement("div");
                overviewDiv.id = 'overviewDiv';
                overviewDiv.setAttribute('style', 'position: absolute;bottom: 1px; right: 1px; width: 300px;height: 200px;border: 1px solid black; z-index: 1;overflow: hidden;');
                eventDiv.id = 'extentDiv';
                eventDiv.setAttribute("style", 'background-color: rgba(0, 0, 0, 0.5); position: absolute; z-index: 2;');
                overviewDiv.append(eventDiv);
                pdm.append(overviewDiv);
                mapView = arcgisModel4X('overviewMapDijit').urlUtils().TileLayer().FeatureLayer().Map().MapView({
                    container: "overviewDiv", constraints: {
                        maxZoom: 14,//最大空间等级  
                        minZoom: 0//最小空间等级  }
                    }
               }).getEsriData("MapView");
                this.setEsriData("overviewMapDijit", arcgisModel4X('overviewMapDijit'));
            }
            mapView.on('mouse-wheel', function (evt) {
                evt.stopPropagation();
            });
            mapView.on('drag', function (evt) {

                evt.stopPropagation();

            });
            mapView.on('double-click', function (evt) {

                evt.stopPropagation();

            });
            // Remove the default widgets
            mapView.ui.components = [];

            var extentDiv = document.getElementById("extentDiv");

            mapView.when(function () {
                var expandFactor = ob.expandFactor || 2;

                // Update the overview extent whenever the MapView or SceneView extent changes
                mainView.watch("extent", updateOverviewExtent);
                mapView.watch("extent", updateOverviewExtent);

                // Update the minimap overview when the main view becomes stationary
                watchUtils.when(mainView, "stationary", updateOverview);

                function updateOverview() {
                    // Animate the MapView to a zoomed-out scale so we get a nice overview.
                    // We use the "progress" callback of the goTo promise to update
                    // the overview extent while animating
                    mapView.goTo({
                        center: mainView.center,
                        scale:
                            mainView.scale *
                            expandFactor *
                            Math.max(
                                mainView.width / mapView.width,
                                mainView.height / mapView.height
                            )
                    });
                }

                function updateOverviewExtent() {
                    // Update the overview extent by converting the SceneView extent to the
                    // MapView screen coordinates and updating the extentDiv position.
                    var extent = mainView.extent;

                    var bottomLeft = mapView.toScreen(
                        new Point({
                            x: extent.xmin,
                            y: extent.ymin,
                            spatialReference: extent.spatialReference
                        })
                    );

                    var topRight = mapView.toScreen(
                        new Point({
                            x: extent.xmax,
                            y: extent.ymax,
                            spatialReference: extent.spatialReference
                        })
                    );

                    extentDiv.style.top = topRight.y + "px";
                    extentDiv.style.left = bottomLeft.x + "px";

                    extentDiv.style.height = bottomLeft.y - topRight.y + "px";
                    extentDiv.style.width = topRight.x - bottomLeft.x + "px";
                }
            });

            return this;
        }
        this.everyGeodesicLength = function (geometry) {

        }
        this.createEvent = function (mod, name, fs) {
            if (typeof ("string")) mod = this.getEsriData(mod);
            if (!mod && !name && !fs) throw Error("参数有误");
            if (!mod.on) throw Error("参数有误");
            return mod.on(name, fs);
        }
        this.refresh = function () {
            if (this.getEsriData("overviewMapDijit")) {
                this.getEsriData("overviewMapDijit").refresh();
            }
            esriData = {};
            this.getPresentUseMap.layers = [];
            this.getPresentUseView = {};
            this.getPresentUseMap = {};
            this.getPresentUseLayers = [];
            this.$GraphicsLayers = [];
            this.$mapLayers = [];
            return this;
        }
        this.createGeometry = function (ob, ob1, ob2) {
            var type = '', spatialReference = ob2 || this.getPresentUseView.spatialReference;
            if (ob1) type = ob1;
            if (typeof (ob) === "number") {
                type = "point";
                return this.tools.Point(ob, ob1, ob2);
            }
            else if (typeof (ob) === "object") {
                if (!type) type = "polyline";
                return { type: type, paths: ob, spatialReference: spatialReference };
            } else {
                return { type: type, paths: ob, spatialReference: spatialReference };
            }
        }
        //加载自定义模块
        each(reqLoad, function (v, k, o) {
            var as = k.split('/')[k.split('/').length - 1];
            var _f = fs[as];
            if (!_f) throw Error(as + "模块还未加载完毕。");
            esriMain[as] = bindArg(function (ob) {
                if (ob === undefined) ob = {};
                var $customEzFs = function (ob) { return _f(ob) };
                if (v.$customEzFs) $customEzFs = v.$customEzFs;
                esriMain.setEsriData(as, $customEzFs.call(this, _f, ob))
                return this;
            }, entrust, v);
        })
    }

    return main;
})(
//导入的模块
{
    "esri/Map": {
        $customEzFs: function (fs, ob) {
            if (ob.layers === undefined) ob.layers = [];
            if (typeof (ob.layers.concat) !== "function") throw Error("layers属性为数组");
            ob.layers = ob.layers.concat(this.$mapLayers);
            var mp = new fs(ob);

            this.getPresentUseMap = mp;
            this.getPresentUseLayers = this.$mapLayers;
            return mp;
        }
    },
    "esri/views/MapView": {
        container: "viewDiv", slider:false,
        nav: false, 
        fadeOnZoom: true,
        force3DTransforms: true,
        slider: true,
        logo: false,
        constraints: {
         
            maxZoom: 17,//最大空间等级  
            minZoom: 7,//最小空间等级  }
           
        },
        zoom: 0,
        center: {
            //x: 118.79, y: 36.34//山东
            x: 117.62, y: 26.27//福建
        },
        $customEzFs: function (fs, ob) {
            var mapView;
            this.getE
            if (!ob.map) {
                ob.map = this.getEsriData("Map");
            }
            mapView = new fs(ob);
            if (!ob.logo) {
                mapView.ui._removeComponents(["attribution"]);
            }
            mapView.container = ob.container;
            this.getPresentUseView = mapView;
            return mapView;
        }
    },
    "esri/layers/TileLayer": {
        $customEzFs: function (fs, ob) {
            var i = 0, titleLayer, arr = ob.url;
            if (typeof (ob.url) === "string" && ob.id == undefined) ob.id = ob.url;
            if (this.getEsriData("TileLayer") == false) this.setEsriData("TileLayer", []); else {
                titleLayers = this.getEsriData("TileLayer");
            }
            if (typeof (arr) != "string")
                while (arr[i]) {
                    ob = {};
                    if (arr[i] === undefined) break;
                    if (typeof (arr[i]) === "string") ob.url = arr[i], ob.id = ob.url;
                    if (typeof (arr[i]) === "object") ob.id = arr[i].id, ob.url = arr[i].url, ob = editObNew(ob, arr[i]);
                    if (ob.id === undefined) ob.id = ob.url;
                    titleLayer = fs(ob);
                    this.addMapLayer(titleLayer);
                    this.setEsriData("TileLayer", titleLayer, 'id')
                    i++;
                }
            else this.addMapLayer(fs(ob));
            return undefined;
        }, url: tileLayer.electron
       
    },
    'esri/core/urlUtils': {

        $customEzFs: function (fs, ob) {

            fs.addProxyRule({
                urlPrefix: arvgisServer,
                proxyUrl: "http://" + location.host + "/DotNet/proxy.ashx"
            });
            return {
                urlPrefix: arvgisServer,
                proxyUrl: "http://" + location.host + "/DotNet/proxy.ashx"
            };

        }
    },
    "esri/config": {
        $customEzFs: function (fs,ob) {
            fs.fontsUrl = "http://" + location.host + "/fonts";
        }
    },
    "esri/Graphic": {
        $customEzFs: function (fs, ob) {
            var fs1 = new fs(ob), layer = ob.$layer, is = true, layerItems = this.getEsriData("Map").layers.items, layers = this.getEsriData("Map").layers, i = 0;
            if (typeof (layer) === "string") layer = this.getMapLayer(layer) || this.GraphicsLayer({ id: layer }).getMapLayer(layer);
            if (layer == undefined) layer = this.getEsriData("GraphicsLayer", { id: "markPoint" }) || this.GraphicsLayer({ id: "markPoint" }).getEsriData("GraphicsLayer", { id: "markPoint" });
            while (layerItems[i]) {
                if (detection(layerItems[i++], { id: layer.id })) { is = false; break };
            }
            if (is) this.addMapLayer(layer);
            layer.graphics.add(fs1);
            return undefined;
        }
    },
    "esri/layers/GraphicsLayer": {
        $customEzFs: function (fs, ob) {
            var graphicsLayer, i = 0;
            if (this.getEsriData("GraphicsLayer") == false) this.setEsriData("GraphicsLayer", []); else {
                graphicsLayer = this.getEsriData("GraphicsLayer");
            }
            if (ob.id === undefined) { console.warn("请在参数的属性里设置id的值,id值不能为空"); return undefined; }
            var layer = new fs(ob);
            this.addMapLayer(layer);
            this.setEsriData("GraphicsLayer", layer, "id")
            return undefined;
        }
    },
    "esri/layers/FeatureLayer": {
        $customEzFs: function (fs, ob) {
            if (this.getEsriData("FeatureLayer") == false) this.setEsriData("FeatureLayer", []);
            var i = 0, layer, arr = ob.url;
            if (typeof (ob.url) === "string" && ob.id == undefined) ob.id = ob.url;
            if (typeof (arr) != "string") {
                while (arr[i]) {
                    ob = {};
                    if (arr[i] === undefined) break;
                    if (typeof (arr[i]) === "string") ob.url = arr[i], ob.id = ob.url;
                    if (typeof (arr[i]) === "object") ob.id = arr[i].id, ob.url = arr[i].url, ob = editObNew(ob, arr[i]);
                    if (ob.id === undefined) ob.id = ob.url;
                    layer = fs(ob);
                    this.addMapLayer(layer);
                    this.setEsriData("TileLayer", layer, 'id')
                    i++;
                }
            }
            else {
                if (!ob.url) ob = {url:ob};
                if (!ob.id) ob.id = ob.url;
                var iFeat = new fs(ob);
                this.addMapLayer(iFeat);
                this.setEsriData("FeatureLayer", iFeat, "id")
            }
            return undefined;
        },
        url:tileLayer.bj
    },
    "esri/widgets/Sketch": {
        $customEzFs: function (fs, ob) {
            var layerItems = this.getEsriData("Map").layers.items
                , layers = this.getEsriData("Map").layers
                , i = 0, is = true
                , fillColor, custom = ob.$customEzAttr || {}
                , iscustom = custom.iscustomAttr, sket, sketFs = custom.updataFs, sketOn = custom.on || {};

            if (ob.view === undefined) ob.view = this.getEsriData("MapView");
            if (ob.layer === undefined) ob.layer = this.getEsriData("GraphicsLayer", { id: "sketch1" }) || this.GraphicsLayer({ id: "sketch1" }).getEsriData("GraphicsLayer", { id: "sketch1" });
            while (layerItems[i]) {
                if (detection(layerItems[i++], { id: ob.layer.id })) { is = false; break };
            }
            if (is) layers.add(this.getEsriData("GraphicsLayer", { id: "sketch1" }));
            delete ob.$customEzAttr;
            delete ob.$customEzFs;
            sket = new fs(ob);
            if (iscustom) {
                // Red stroke, 1px wide                  
                if (typeof (sketFs) === "function") sketFs(sket);
                each(sketOn, function (v, k) {
                    sket.on(k, v);
                })
            }
            return sket;
        },
        $customEzAttr: {
            updataFs: function (sket) {
                var fillColor = [255, 255, 255, .5];
                var stroke = {
                    color: [255, 0, 0],
                    width: 1
                }
                // Override all default symbol colors and sizes
                var pointSymbol = sket.viewModel.pointSymbol;
                pointSymbol.color = fillColor;
                pointSymbol.outline = stroke;
                pointSymbol.size = 1;
                var polylineSymbol = sket.viewModel.polylineSymbol;
                polylineSymbol.color = stroke.color;
                polylineSymbol.width = stroke.width;
                var polygonSymbol = sket.viewModel.polygonSymbol;
                polygonSymbol.color = fillColor;
                polygonSymbol.outline = stroke;
            },
            on: {
                "create": function (event) {

                    if (event.state === "complete") {
                        var gs = event.graphic;
                        var graphics = arcgisModel4X.calculateGeometry(gs), i = 0, items = gs.layer.graphics;
                        setTimeout(function (graphics, items) {;
                            for (var i = graphics.length; i;i--) {
                                items.add(graphics[i - 1]);
                            }
                        }.bind(undefined, graphics, this.layer.graphics), 1000 / 3)
                    }
                },
                'update': function (event) {
                    if (event.graphics[0].geometry.type != "polygon" && event.graphics[0].geometry.type != "polyline" || event.graphics[0].geometry.center) {
                        this.cancel();
                    }
                    if (event.state === "complete") {
                        var gs = event.graphics[0];
                        arcgisModel4X.removeGraphic(this.layer, function (g) { if (g.attributes && (g.attributes.id == gs.uid)) return true; })
                        var graphics = arcgisModel4X.calculateGeometry(gs), i = 0, items = gs.layer.graphics;
                        while (graphics[i]) {
                            items.add(graphics[i]);
                            i++;
                        }
                       
                    }
                }
            },
            iscustomAttr: true
        }
    }
},//自定义接口 及arcgis 工具模块
{
    overviewMapDijit: {//鹰眼默认值
        width: 310,   // 默认值是地图高度的 1/4th
        height: 320, // 默认值是地图高度的 1/4th
        opacity: .30,  // 透明度 默认0.5
        expandFactor: 2,    //概览地图和总览图上显示的程度矩形的大小之间的比例。默认值是2,这意味着概览地图将至少是两倍的大小的程度矩形。
        color: "#000000",  // 默认颜色为#000000           
    }//自定义鹰眼

}
)






使用方式

//这里大部分arcgis的方法必传的参数都设置了默认值 传入相同属性的值货参数就可以顶替掉
arcgisModel4X('b')
.urlUtils()//设置配置
.TileLayer()//生成图层参数可以参考arcgis 的TileLayer
.FeatureLayer()//生成图层参数可以参考arcgis 的FeatureLayer
.GraphicsLayer()//生成图层参数可以参考arcgis 的GraphicsLayer
.Map()//生成map 并把所有创建好的图层都加进来 其他参数参考arcgis 的Map
.MapView()//生成view 并把map带入进去
.Sketch()
.overviewMapDijit();//生成鹰眼 这个是自定义的方法
/*鹰眼参数如下
//鹰眼默认值
        mapView:MapView对象,//如果不传这个方法内会创建一个然后跟主地图关联起来
        width: 310,   // 默认值是地图高度的 1/4th
        height: 320, // 默认值是地图高度的 1/4th
        opacity: .30,  // 透明度 默认0.5
        expandFactor: 2,    //概览地图和总览图上显示的程度矩形的大小之间的比例。默认值是2,这意味着概览地图将至少是两倍的大小的程度矩形。
        color: "#000000",  // 默认颜色为#000000           
    }//自定义鹰眼
*/

demo

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8" />
    <meta
      name="viewport"
      content="initial-scale=1,maximum-scale=1,user-scalable=no"
    />
    <title>Editor widget with configurations - 4.11</title> 
      <link href="Javascript/ArcGIS/4.11/esri/css/main.css" rel="stylesheet" />
      <script src="Javascript/ArcGIS/4.11/init.js"></script>
    <script src="Javascript/arg4.js"></script>
    <style>
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }

      .esri-editor .esri-item-list__scroller {
        max-height: 350px;
      }
    </style>
      
    <script>
        
        arcgisModel4X.onLoadEnd = function () {
            var i = 0;
            var item = {};
            arcgisModel4X('b').urlUtils().TileLayer().FeatureLayer({url: "https://services3.arcgis.com/GVgbJbqm8hXASVYi/arcgis/rest/services/Trails_Styled/FeatureServer/0"}).GraphicsLayer().Map().MapView().Sketch().overviewMapDijit();

                     
            ChangeMap = arcgisModel4X('b').changeLayer;
            sketch = arcgisModel4X('b').geometrySing;
        }
      
        
    </script>
  </head>

  <body>
    <div id="viewDiv">
         <div id="Map_Tools_RightTopPanel" style="top: 10px; right: 5px; position: absolute; z-index: 30;">
                        <div style="width: 100%; height: 100%;">
                            <div style="float: left; width: 45px; padding: 0px; border: none;">
                                <a onclick="Map_Menus_RightTop_FullScreen()" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-full',size:'large',iconAlign:'top'">全屏</a>
                                <a onclick="ChangeMap()" href="#" style="margin-top: 5px;" class="easyui-linkbutton" data-options="iconCls:'icon-dzdt',size:'large',iconAlign:'top'">电子</a>
                                <a onclick="ChangeMap()" href="#" style="margin-top: 5px;" class="easyui-linkbutton" data-options="iconCls:'icon-yxdt',size:'large',iconAlign:'top'">影像</a>
                                <a onclick="sketch('polyline')" style="margin-top: 5px;" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-juli',size:'large',iconAlign:'top'">距离</a>
                                <a onclick="sketch('polygon')" style="margin-top: 5px;" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-mianji',size:'large',iconAlign:'top'">面积</a>
                                <a onclick="circle(circle)" style="margin-top: 5px;" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-qingkong',size:'large',iconAlign:'top'">清空</a>
                                <a onclick="sketch('circle')" style="margin-top: 5px;" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-fujin',size:'large',iconAlign:'top'">附近</a>

                                
                                <a onclick="_print()" style="margin-top: 5px;" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-dayin_2',size:'large',iconAlign:'top'">打印</a>

                            </div>
                            <div id="info_div" style="width: 230px; border: 0px; display: none; float: left">
                                <!--
                                <div>
                                    <p id="info_div_location"></p>
                                    <ul id="info_div_ul"></ul>
                                </div>
                                    -->
                                <!--右侧弹出开始-->
                                <div class="tanchu" style="top: 0px;">
                                    <div class="tanchulan1 font14" id="info_div_location">
                                    </div>
                                   
                                    <div class="tanchucont1" id="info_div_ul">
                                    </div>
                                </div>
                                <!--右侧弹出结束-->
                            </div>
                        </div>

                    </div>
    </div>

  </body>

    
</html>

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值