zoukankan      html  css  js  c++  java
  • 根据条件渲染FeatureLayer以及FindTask使用注意事项

    1、条件渲染

    arcgis api for js 提供了多种渲染方式 根据需求自行设置

    下面分别为4.x 和3.x 提供的方式

     2、FindTask 使用注意事项

    在使用FindTask时 查询出的数据中 geometry为空

    原因:参数FindParameters 的returnGeometry默认为false 将其改为true

    3、查出结果 并进行缩放示例代码

    function zoomFourMap(filedValue) {
    
        require([
            "esri/tasks/FindTask",
            "esri/tasks/FindParameters",
            "esri/geometry/Extent",
            "esri/SpatialReference",
            "dojo/domReady!"
        ], function(
            FindTask, FindParameters,
            Extent,
            SpatialReference
        ) {
            let find, params;
            find = new FindTask("url");
            params = new FindParameters();
            params.layerIds = [1];
            params.searchFields = ["Filed"];
            params.searchText = filedValue
            params.returnGeometry = true;
            find.execute(params, (res) => {
    
                let xArr = [];
                let yArr = [];
                if (res.length > 0) {
                    for (let j = 0; j < res.length; j++) {
                        const o = res[j];
                        o.feature.geometry.rings[0].forEach(xy => {
                            xArr.push(xy[0])
                            yArr.push(xy[1])
                        });
                    }
                }
                const xMax = Math.max(...xArr);
                const xMin = Math.min(...xArr)
                const yMax = Math.max(...yArr)
                const yMin = Math.min(...yArr)
    
                const spatialReference = new SpatialReference({
                    wkt: 'PROJCS["CGCS2000_3_Degree_GK_CM_118.52E",GEOGCS["GCS_China_Geodetic_Coordinate_System_2000",DATUM["D_China_2000",SPHEROID["CGCS2000",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Gauss_Kruger"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",118.86666667],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]'
                })
                const myExtent = new Extent(xMin, yMin, xMax, yMax, spatialReference)
    
                map.setExtent(myExtent)
    
            });
        })
    
    }
  • 相关阅读:
    增强MyEclipse提示功能
    Mysql安装配置,修改初试密码。
    在我的电脑里面创建图标
    popup non topmost
    多线程下载或上传数据限速
    SynchronizationContext
    linux运维笔记——常用命令详解diff
    linux运维笔记——curl
    linux下mysql的源码安装
    shell编程——变量的数值计算
  • 原文地址:https://www.cnblogs.com/xiaoqiyaozou/p/14651691.html
Copyright © 2011-2022 走看看