【问题标题】:ESRI ArcGIS Javascript API RelationshipQuery classESRI ArcGIS Javascript API 关系查询类
【发布时间】:2015-03-17 15:20:22
【问题描述】:

我在使用 ESRI ArcGIS Javascript API 关系查询类时遇到问题。

我正在尝试使用 RelationshipQuery 类从我的 GIS 服务中的不同 GIS 层(在本例中为第 1 层)获取字段。换句话说,我希望在第 1 层中抓取具有与单击点的评估者图层 FeatureLayer 对象中的 SCTM 字段相同的 SCTM 字段的记录,以便我可以将所有信息填充到一个弹出窗口中。

这是我关于 RelationshipQuery 类的代码段

var title, content, graphicAttributes;

        var relatedQuery = new RelationshipQuery();
        relatedQuery.relationshipId = 1;
        relatedQuery.outFields = ["*"];


        assessorLayer.on("click", function(evt) 
        { /* start assessorLayer.on click event */

            graphicAttributes = evt.graphic.attributes;  

            title = "Assessor";
            content = "<b>Name: </b>" + graphicAttributes.OWNER_NAME + graphicAttributes.OWNER_NAME2
                    + "<br><b>Dimensions: </b>" + graphicAttributes.DIMENSIONS
                    + "<br><b>Garbage District: </b>" + graphicAttributes.CBA;

            relatedQuery.definitionExpression = ("SCTM = " + graphicAttributes.SCTM);

            assessorLayer.queryRelatedFeatures(relatedQuery, function(relatedRecords) 
            { /* start assessorLayer.queryRelatedFeatures function */
               var status = relatedRecords[graphicAttributes.STATUS];

                content = content + "<br><hr><br> Status: " + status; 


                map.infoWindow.setTitle(title);
                map.infoWindow.setContent(content);
                map.infoWindow.show(evt.screenPoint, map.getInfoWindowAnchor(evt.screenPoint));*/

            }); /* End assessorLayer.queryRelatedFeatures function */


        }); /* End assessorLayer.on click event */

【问题讨论】:

    标签: javascript arcgis esri arcgis-js-api


    【解决方案1】:

    你需要为关系查询设置objectid,所以你可以在assessorLayer.on("click", function(evt) 处理程序中添加

    relatedQuery.objectIds = [evt.features[0].attributes.OBJECTID];
    

    另一个选项是使用弹出模板相关字段语法,以便弹出窗口自动查询相关表的功能并相应地填充自己。 JS API documentation 有这样的例子

    【讨论】:

      猜你喜欢
      • 2018-04-11
      • 2022-01-16
      • 2018-11-21
      • 1970-01-01
      • 2020-08-28
      • 2020-01-18
      • 1970-01-01
      • 2013-06-15
      • 2013-04-13
      相关资源
      最近更新 更多