操作方法
通过编辑 [install dir]\server\[app#]\configs 中的 config_Search.json 文件和 [install Dir]\server\apps\[app #]\widgets\Search 中的 Widget.js 文件在 Web AppBuilder for ArcGIS 中将“搜索”微件的结果限制为特定范围。
以下代码片段演示了如何将搜索微件的结果限制为特定范围。
添加 searchExtent 变量,其中包括最小和最大的 x 和 y 坐标,如下所示:
"type": "locator", "searchExtent": { "xmin": -9589858.361942431, "ymin": 3964964.109405532, "xmax": -9522593.777051566, "ymax": 4031693.635098401, "spatialReference": { "wkid": 102100 } }
按照上面的代码,现在脚本开头中的 require 列表中需要 Extent。
require([ ... 'esri/geometry/Extent', ... ], function()
在 config_Search.json 文件中添加的变量随后将在 [install Dir]\server\apps\[app #]\widgets\Search 中的 Widget.js 文件中检索,以创建新范围对象,并引用在 config_Search.json 文件中设置的最小和最大的 x 和 y 坐标。
if (source && source.url && source.type === 'locator') { locator: new Locator(source.url || ""), outFields: ["*"], singleLineFieldName: source.singleLineFieldName || "", name: source.name || "", placeholder: source.placeholder || "", countryCode: source.countryCode || "", maxResults: source.maxResults || 6 }; if(source.searchExtent){ locSource.searchExtent = new Extent(source.searchExtent); } return locSource; }
从 ArcGIS 专家处获得帮助
下载 Esri 支持应用程序