我正在尝试访问特定ArcGIS WebMap图层的属性。我已经将一个单击处理程序附加到WebMap React组件,但我只能从基本映射访问mapPoint.latitude和mapPoint.longitude值(在事件中)。
例如,从第4层开始,当我单击地图的特定区域时,我想访问“位置名称”的自定义值。
简化的示例代码:
clickHandler = e => {
console.log(e.mapPoint.latitude + ", " + e.mapPoint.longitude);
};
...
<WebMap
viewProperties={{
center: [ this.props.latitude, this.props.longitude ],
zoom: 12
}}
mapProperties={{ basemap: "streets" }}
onClick={e => this.clickHandler(e)}
id="9a9a9a9aaaccc1234"
/>
如您所见,点击处理程序仅为您提供mapPoint坐标。
为了从该mapPoint的特定Featurelayer获取信息,您需要在感兴趣的FeatureLayer上使用IdentifyTask或QueryTask,使用mapPoint中的坐标作为查询几何。请参阅文档中有关如何精确执行此操作的示例。