ArcGIS API for Js 之 QueryTask详解

ArcGIS JavaScript API中的QueryTask报错解决方法 在使用ArcGIS JavaScript API进行QueryTask操作时,有时候可能会遇到一些错误。本文将介绍一些常见的错误,并提供解决方法和相应的源代码示例。以上是一些常见的ArcGIS JavaScript API中QueryTask报错的解决方法。希望这些信息对您有帮助!// 在这里编写 QueryTask 相关的代码。 阅读详情

ArcGIS API for Js 之 QueryTask详解

实现功能说明
  • 明白Query和QueryTask之间的关系
  • 实现发布图层属性信息的相关查询
  • 结合3D符号和信息模板弹出进行相关可视化展示
  • dojo/_base/array的相关机制
实现的相关代码
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no">
  <meta name="description" content="[Query Task - 4.3]">
  <!-- 
  ArcGIS API for JavaScript, https://js.arcgis.com
  For more information about the tasks-query sample, read the original sample description at developers.arcgis.com.
  https://developers.arcgis.com/javascript/latest/tasks-query/index.html  
  -->
  <title>Query Task - 4.3</title>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }

    #optionsDiv {
      background-color: dimgray;
      color: white;
      z-index: 23;
      position: absolute;
      top: 0px;
      right: 0px;
      padding: 0px 0px 0px 10px;
      border-bottom-left-radius: 5px;
      max-width: 350px;
    }

    .esri-popup .esri-popup-header .esri-title {
      font-size: 18px;
      font-weight: bolder;
    }

    .esri-popup .esri-popup-body .esri-popup-content {
      font-size: 14px;
    }
  </style>

  <link rel="stylesheet" href="https://js.arcgis.com/4.3/esri/css/main.css">
  <script src="https://js.arcgis.com/4.3/"></script>

  <script>
    require([
      "esri/Map",
      "esri/views/SceneView",
      "esri/layers/GraphicsLayer",
      "esri/symbols/PointSymbol3D",
      "esri/symbols/ObjectSymbol3DLayer",
      "esri/tasks/QueryTask",
      "esri/tasks/support/Query",
      "dojo/_base/array",
      "dojo/dom",
      "dojo/on",
      "dojo/domReady!"
    ], function(
      Map, SceneView, GraphicsLayer, PointSymbol3D, ObjectSymbol3DLayer,
      QueryTask, Query, arrayUtils, dom, on
    ) {

      // URL to feature service containing points representing the 50 
      // most prominent peaks in the U.S. 
      var peaksUrl =
        "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/Prominent_Peaks_US/FeatureServer/0";

      // Define the popup content for each result    
      var popupTemplate = { // autocasts as new PopupTemplate()
        title: "{MTN_PEAK}, {STATE}",
        fieldInfos: [{
          fieldName: "ELEV_ft",
          label: "Elevation (feet)",
          format: {
            places: 0,
            digitSeperator: true
          }
        }, {
          fieldName: "ELEV_m",
          label: "Elevation (meters)",
          format: {
            places: 0,
            digitSeperator: true
          }
        }, {
          fieldName: "PROMINENCE_ft",
          label: "Prominence (feet)",
          format: {
            places: 0,
            digitSeperator: true
          }
        }, {
          fieldName: "PROMINENCE_m",
          label: "Prominence (meters)",
          format: {
            places: 0,
            digitSeperator: true
          }
        }, {
          fieldName: "ISOLATION_mi",
          label: "Isolation (miles)",
          format: {
            places: 0,
            digitSeperator: true
          }
        }, {
          fieldName: "ISOLATION_km",
          label: "Isolation (km)",
          format: {
            places: 0,
            digitSeperator: true
          }
        }],
        content: "<b><a href='https://en.wikipedia.org/wiki/Topographic_prominence'>Prominence:</a>" +
          "</b> {PROMINENCE_ft} ft ({PROMINENCE_m} m)" +
          "<br><b>Prominence Rank:</b> {RANK}" +
          "<br><b>Elevation:</b> {ELEV_ft} ft ({ELEV_m} m)" +
          "<br><b><a href='https://en.wikipedia.org/wiki/Topographic_isolation'>Isolation:</a>" +
          "</b> {ISOLATION_mi} mi ({ISOLATION_km} km)"
      };

      var mtnSymbol = new PointSymbol3D({
        symbolLayers: [new ObjectSymbol3DLayer({
          resource: {
            primitive: "cone"
          }
        })]
      });

      // Create graphics layer and symbol to use for displaying the results of query    
      var resultsLyr = new GraphicsLayer();

      /*****************************************************************
       *  Point QueryTask to URL of feature service  
       *****************************************************************/
      var qTask = new QueryTask({
        url: peaksUrl
      });

      /******************************************************************    
       * Set the query parameters to always return geometry and all fields.
       * Returning geometry allows us to display results on the map/view
       ******************************************************************/
      var params = new Query({
        returnGeometry: true,
        outFields: ["*"]
      });

      var map = new Map({
        basemap: "osm",
        layers: [resultsLyr] // add graphics layer to the map
      });

      var view = new SceneView({
        map: map,
        container: "viewDiv",
        center: [-100, 38],
        zoom: 4
      });

      var attributeName = dom.byId("attSelect");
      var expressionSign = dom.byId("signSelect");
      var value = dom.byId("valSelect");

      // Executes each time the button is clicked    
      function doQuery() {
        // Clear the results from a previous query
        resultsLyr.removeAll();
        /*********************************************
         *
         * Set the where clause for the query. This can be any valid SQL expression.
         * In this case the inputs from the three drop down menus are used to build
         * the query. For example, if "Elevation", "is greater than", and "10,000 ft" 
         * are selected, then the following SQL where clause is built here:
         * 
         * params.where = "ELEV_ft > 10000";  
         * 
         * ELEV_ft is the field name for Elevation and is assigned to the value of the
         * select option in the HTML below. Other operators such as AND, OR, LIKE, etc
         * may also be used here.
         *
         **********************************************/
        params.where = attributeName.value + expressionSign.value + value.value;

        // executes the query and calls getResults() once the promise is resolved
        // promiseRejected() is called if the promise is rejected
        qTask.execute(params)
          .then(getResults)
          .otherwise(promiseRejected);
      }

      // Called each time the promise is resolved    
      function getResults(response) {
        console.log(response.features);
        // Loop through each of the results and assign a symbol and PopupTemplate
        // to each so they may be visualized on the map
        var peakResults = arrayUtils.map(response.features, function(
          feature) {

          // Sets the symbol of each resulting feature to a cone with a 
          // fixed color and width. The height is based on the mountain's elevation
          feature.symbol = new PointSymbol3D({
            symbolLayers: [new ObjectSymbol3DLayer({
              material: {
                color: "green"
              },
              resource: {
                primitive: "cone"
              },
              width: 100000,
              height: feature.attributes.ELEV_m * 100
            })]
          });

          feature.popupTemplate = popupTemplate;
          //feature is an object 
          return feature;
        });

        resultsLyr.addMany(peakResults);

        // animate to the results after they are added to the map  
        view.goTo(peakResults);
        // print the number of results returned to the user
        dom.byId("printResults").innerHTML = peakResults.length +
          " results found!";
      }

      // Called each time the promise is rejected    
      function promiseRejected(err) {
        console.error("Promise rejected: ", err.message);
      }

      // Call doQuery() each time the button is clicked    
      on(dom.byId("doBtn"), "click", doQuery);
    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
  <div id="optionsDiv">
    <h2>Prominent Peaks in the U.S.</h2>
    <select id="attSelect">
      <option value="ELEV_ft">Elevation</option>
      <option value="PROMINENCE_ft" selected>Prominence</option>
    </select>
    <select id="signSelect">
      <option value=">">is greater than</option>
      <option value="<">is less than</option>
      <option value="=">is equal to</option>
    </select>
    <select id="valSelect">
      <option value="1000">1,000 ft</option>
      <option value="5000">5,000 ft</option>
      <option value="10000">10,000 ft</option>
      <option value="15000">15,000 ft</option>
      <option value="20000">20,000 ft</option>
      <option value="PROMINENCE_ft">Prominence</option>
    </select>
    <br>
    <br>
    <button id="doBtn">Do Query</button>
    <br>
    <p><span id="printResults"></span></p>
  </div>
</body>

</html>
需要注意的是
  1. 3D符号的建立。怎么说呢,Esri很套路的告诉我们所需要的符号还给我们扩展,很官方的夸赞是让编程更加的简单。详细了解还是得看API 还有和你们分享一个生成符号的示例吧。

[干货] https://developers.arcgis.com/javascript/latest/sample-code/playground/live/index.html#/config=symbols/3d/PointSymbol3D.json)

2.注意Query和QueryTask的关系和区别分别都有什么参数,如何调用。Query相当于是SQL语句啊,QueryTask就是Query执行环境,以及返回结果的通道。我是简单的来说的,具体详细的还是得看API。

3.注意发布的图层,首先搞清楚图层中存在什么属性,目标要查询什么属性,明白后就很简单的调用了。

  1. 值得一提的就是dojo/_base/array的map方法吧:

还有相关的原型,这是有关原生JS的,看还是挺有帮助的。

实现的效果

如果读者有兴趣,还可以东西更多
  • 自定义样式,自我形象打扮由自己决定
  • 自己再玩玩其它属性啦,什么的。
  • 简单点讲,API玩不好,就是你被玩,玩好了,就是你玩它。

优雅的玩技术

在GIS的沙场,传播有价值的东西!

arcgis api for javascript 之QueryTask查询 共享作业 arcgis api for javascript 之QueryTask查询 立即下载

相关推荐

LRTimelapse Pro v7.0.0 激活版下载安装教程 (延迟摄影后期渲染)

LRTimelapse Pro 是一款优秀的高级延时摄影解决方案,使用将为用户提供最全面的工具和功能,从导入和组织您的延时摄影序列、视觉工作流程、在 LRTimelapse 中直接编辑和渲染、视觉去闪烁等等,功能齐全,可以使用 LRTimelapse Pro 编辑多个序列时显著提高您的效率,轻松在 LRTimelapse 中配置和使用色彩管理,进行长期延时编辑,在 LRTimelapse Pro 中使用长期工作流程。为延时编辑、关键帧、分级和渲染提供最全面的解决方案。

wyqshusan的博客 3464

acrgis api for javaScript中的FeatureLayer查询

acrgis api for javaScript中的FeatureLayer查询:1. 用api查询 &lt;script&gt; require([ "dojo/dom", "dojo/on", "esri/tasks/query", "esri/tasks/QueryTask", "dojo/domReady!"

春华秋实 947

Windows Server 2022域控环境下的MDT部署工具安装与配置避坑指南

本文详细介绍了在Windows Server 2022域控环境中安装和配置MDT(Microsoft Deployment Toolkit)的全流程,包括ADK与Windows PE的精准安装、MDT高级配置、部署工作流构建及性能优化技巧。通过实战指南帮助IT管理员实现自动化系统部署,提升企业IT运维效率,特别适用于需要静默下发系统的大规模部署场景。

weixin_28481133的博客 435

ArcGIS API For JavaScript官方文档(十一)使用QueryTask

    QueryTask、Query和FeatureSet一起用于查询地图中的一个图层并显示结果。    用户向Query提供输入参数,此输入参数可能包括选择地图上的要素的信息。输入参数用于创建查询筛选器。在流程的下一步,QueryTask根据查询筛选器执行查询任务。在流程的最后一步,结果被当做FeatureSet返回,这些结果包括为高亮地图上的要素而选择的每个要素的geometry,它还包括用...

不睡觉的怪叔叔的博客 4584

Chapter 4 Ripple-Based Control Technique Part I

本文介绍了DC-DC转换器的纹波控制技术,重点分析了迟滞控制、恒定开通时间控制、恒定关断时间控制等方案的工作原理及优缺点。纹波控制无需补偿网络,具有快速瞬态响应和结构简单的优势,特别适合电池供电应用。其中,恒定开通时间控制在轻载时能自动延长关断时间,实现伪定频工作;而恒定关断时间控制轻载效率较低。文章还讨论了纹波注入技术解决Boost转换器右半平面零点问题,并比较了不同控制方案在负载瞬态下的性能表现。最后指出基于纹波的控制技术在提高调节精度和降低EMI方面的改进方向。

2304_76736886的博客 1300

AI算力瓶颈与系统优化实战指南

AI算力瓶颈已成为制约人工智能发展的关键因素,特别是在处理transformer类模型时,传统的冯·诺依曼架构面临严重的'内存墙'问题。通过硬件加速、系统优化和算法改进的三级策略,可以有效提升资源利用率。在嵌入式AI领域,结合量化、剪枝和专用指令集扩展等技术,能在资源受限设备上实现高效推理。这些优化方法在自动驾驶、工业视觉等场景中已展现出显著价值,推动AI应用从云端向边缘迁移。随着AI算力需求的持续增长,掌握系统优化技能将成为开发者的核心竞争力。

weixin_32597009的博客 339

查询---QueryTask空间查询

1. 效果图 2. QueryTask属性查询和空间查询的不同 引入模块不同 空间查询多了"esri/toolbars/draw",模块 条件格式 //定义一个绘图工具 var toolBar = new Draw(map); //给button绑定事件 on(dom.byId("Btn"),"click",function(){ //激活绘图工具,我要绘制一个面图形 toolBa...

DanBo_C的博客 615

iPhone用户必看:不装App也能搞定GitHub 2FA验证的3种方法(附恢复码管理技巧)

本文为iPhone用户提供了无需安装第三方App即可完成GitHub双重身份验证(2FA)的三种原生方案:利用相机扫码与iCloud钥匙串自动填充、使用iCloud钥匙串内置的TOTP验证码生成器,以及借助Safari浏览器扩展。文章详细解析了每种方法的操作步骤、适用场景,并重点强调了恢复码的安全管理与多层备份策略,帮助开发者在提升账户安全的同时,享受苹果生态的无缝便捷体验。

weixin_29324401的博客 652

arcgis api for JavaScript学习-查询QueryTask

QueryTask QueryTask:用于属性查询和空间查询,可以进行简单统计,只能查询一个图层。 思路: 创建需要的对象QueryTask、Query、渲染符号SimpleLineSymbol等。 设置查询参数Query 执行查询 渲染查询结果 示例代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>QueryTask之属性

Zzzpiu的博客 1300

手把手教你用DaVinci Configurator配置AUTOSAR SWC接口(含RTE避坑指南)

本文提供了一份基于DaVinci Configurator工具的AUTOSAR软件组件(SWC)接口配置实战指南。文章详细拆解了SR(发送者-接收者)和CS(客户端-服务器)接口的配置流程,并重点分享了运行时环境(RTE)生成阶段在多核部署、数据类型匹配等常见陷阱中的避坑方案与调试技巧,旨在帮助汽车电子工程师高效完成配置并规避错误。

uuu88的博客 547

RK3588 固定hdmiin的dev/videoX节点

RK3588 固定hdmiin的dev/videoX节点

目前从事linux驱动开发,多交流多学习吧 2050

arcgis api for js学习-QueryTask简化版

QueryTask简化版 文章目录前言一、QueryTask、FindTask、IdentifyTask之间的区别二、QueryTask使用步骤1.创建QueryTask对象2.创建Query并设置参数3.执行查询4.渲染查询结果三、全部代码总结 前言 QueryTask用于查询,可以进行属性查询和空间查询,但是只能查询一个图层的数据。与之搭配使用的是Query,用于设置查询的参数。 一、QueryTask、FindTask、IdentifyTask之间的区别 FindTask:只能进行属性查询,可以

Zzzpiu的博客 667

微信小程序 - 最新详细实现调起手机摄像头拍摄身份证人像面和国徽面取景框功能,在拍照相机上增加身份证证件照的轮廓或自定义文字,支持替换扫描拍摄辅助线图片及文本,小程序实现拍照身份证时带取景轮廓框拍摄!

微信小程序,身份证,证件照,人像,证件照提示框模板,vue身份证拍照框,摄像机相机里有引导内容,取景框拍摄,微信小程序实现拍照界面自定义实现,自拍人相框拍摄,取景框,户口簿取景框,画布指定区域生成图片,微信小程序身份证正反面拍照如何加入辅助图片引导照片,身份证取景框拍摄,服务器,上传,正反面,调起手机摄像头:拍摄身份证的正反面,自定义身份证取景框,在相机上绘制“身份证轮廓“与提示文字,拍摄身份证时出现人像框怎么实现,在相机上增加图片和文字,微信小程序怎么给调起的相机加入自定义图片,小程序实现给相机上面

🏆 前端领域优质创作者 1万+

ArcGIS API For JavaScript——空间查询(QueryTask)

ArcGIS API For JavaScript提供了两个工具类用于查询任务 IdentifyTask:利用该工具类可以对多个图层进行查询,主要利用IdentifyParameters对象来规定空间查询的参数。 QueryTask:该工具只能对一个图层进行查询,但是利用该类进行查询的时候课指定属性过滤,所以可以同时进行几何和属性查询。该工具主要利用Query类来设定查询参数。 本...

GISXX 1万+

OV9734 DATASHEET,完整规格书

OV9734完整规格书,包括电气参数,尺寸规格,寄存器配置表等

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

ArcGIS API For JavaScript - QueryTask、FindTask查询

图层要素QueryTask、FindTask查询一. QueryTask查询二. FindTask查询 一. QueryTask查询 注意:只能查询单个图层。 QueryTask进行查询的地图服务并不必项加载到Map中进行显示。QueryTask的执行需要两个先决条件:一个是需要查询的图层URL、一个是进行查询的过滤条件。 @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="

技术共享,共同进步! 652

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

ArcGIS API For Javascript 之 QueryTask单图层查询

require([ "esri/tasks/QueryTask","esri/tasks/query","esri/SpatialReference" ], function(QueryTask,Query,SpatialReference) { var queryTask =new QueryTask("http://localhost/arcgis/...

wangchaohpu的博客 1515

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

arcgis api for js 之queryTask查询

where子句 1=1 and substring(xzqdm,1,4)='1401'

flyxiaokang的博客 497

ArcGIS.Server.9.3和ArcGIS API for JavaScript实现语句查询QueryTask(八)

目的: 1.ArcGIS.Server.9.3和ArcGIS API for JavaScript实现语句查询能,通过QueryTask实现,根据输入的查询语句对指定图层进行查询然后把查询到的地理元素进行高亮显示,并且给查询到的元素添加鼠标移上去显示信息的功能。 准备工作: 1. 在ArcGis Server9.3中发布名为usa的MapServer。 2.在使用在线的http://ser

原创盗版的专栏 1265

ArcGIS API for JavaScript 查询通过QueryTask查找要素,对要素进行缓冲区分析,计算要素面积

GeometryEngine使用 缓冲区分析,面积计算 <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" /> <title> GeometryEngine </

体验新模板 905

ArcGIS api for javascript querytask 返回结果上限1000的问题

我用的是ArcServer 10.2,打开ArcCatalog找到自己发布的服务,右键Service Properties,左侧点击Parameters,右侧有一个Maximum number of records returned by the server,修改一下上限就行了 转载于:https://www.cnblogs.com/ahnugiser-yylf/p/7237955.html...

weixin_30477797的博客 423

Arcgis Api for JavaScript ——queryTask中url出现自动符号转义,&-》&

 如题,正确的代码是 var queryTask = new esri.tasks.QueryTask(url.trim()); 原因在于输入的url含有空格,自动转义,并拼接当前的href

Amesteur的博客 516

ArcGIS API For Javascript中queryTask查询返回结果限制为1000的解决办法

更改ArcGIS Server目录下的某个文件即可

ldldong的专栏 5956

ArcGIS API for JavaScript 解决identify Task 和QueryTask查询结果限制(1000)问题

需求 利用ArcGIS API for JavaScript进行identify Task或者是QueryTask进行大量查询的时候,发现返回的查询结果最大为1000个,不符合实际的生产需求。 官方说明文档 To prevent queries that request unlimited numbers of features (e.g., empty WHERE statements...

idomyway的博客 3055

ArcGIS API for JavaScript中要素图层查询(地图外搜索点击查询)的方法总结

1.Arcgis API for JavaScript中常见的三种查询方式 在Arcgis API for JavaScript中常见的属性查询有三种方式:QueryTask,FindTask,IdentifyTask.【具体用法请参考官网示例】 QueryTask:只可在要素服务(featurelayer)或者某个地图服务(MapImageLayer)的某个子图层进行查询(如下图,你发布的地图服务必须要可以支持query才可以,发布服务如果为featurelayer其本身就支持,如果发布为MapI

韦_恩的博客 7276
上一篇: ArcGIS API For Js 的PopTemplete擴展
下一篇: 菜鸟速成记-IDL初识
Yao.Li
博客等级 码龄10年 405粉丝 110原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yao.Li

爱的魔力,一被卡布奇诺~

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值