arcgis api for js4.x实现点击GraphicsLayer上绘制的Graphic获取Graphic中的attributes中的信息

需求:arcgis api for js4.x

在Map地图中添加GraphicsLayer图层,在GraphicsLayer图层添加绘制graphics点,点击绘制的点,获取graphics点中的attributes中的信息

javascript 复制代码
var cityCenter = new Point(116, 36, new SpatialReference({ wkid: 4490 }));
var map = new Map({
    basemap: {
      baseLayers: [layer1]
    },
    layers:[layer2,layer3]
});
//视图
var view = new MapView({
    container: "viewDiv",
    map: map,
	center: cityCenter,
	zoom: 12,
});
//创建一个图层
var graphicsLayer = new GraphicsLayer({
    graphics: [],
    visible: true,
    id:"layerid"
});
//创建要素graphic
var graphic = new Graphic({
    geometry: point,
    symbol: symbol,
	attributes:{
		'aa':'aaaa',
		'bb':'bbbb'
    }
});
//添加要素
graphicsLayer.graphics.add(graphic)

view.on("click", (event) => {
    view.hitTest(event).then(function(response) {
        if (response.results.length) {
            var graphic = response.results.filter(function(result) {
            // check if the graphic belongs to the layer of interest
                return result.graphic.layer.id === 'layerid';
            })[0].graphic;
			console.log(graphic.attributes);//获取graphic中的attributes
        }
    })
})

参考:arcgis api for js4.x实现点击图层上的绘制的Graphics点,弹出点信息。_accessor#set invalid property value, value needs t-CSDN博客

相关推荐
玩大数据的龙威3 天前
农经权二轮延包—固定比例尺不定图幅的公示图批量生成
python·arcgis·二轮延包公示图
非科班Java出身GISer13 天前
ArcGIS JS 基础教程(38):StreamLayer 实时流数据图层
arcgis·arcgis js·arcgis js 流图层·streamlayer·arcgis 流数据图层·arcgis 实时流数据图层
赵钰老师14 天前
基于ArcGIS Pro、R、INVEST等多技术融合下生态系统服务权衡与协同动态分析
python·arcgis·数据分析·r语言
梦想的初衷~15 天前
MaxEnt 物种分布建模学习手册|理论 + R 语言 + ArcGIS 全套实操教程
arcgis·环境变量·r 语言·maxent 模型·物种分布建模·生态学研究·科研教程
jiushidt20 天前
ArcGIS Pro Add‑in 打包流程详解
arcgis·c#·.net·arcgispro
蓝悦无人机20 天前
《地面站软件开发》-第2章ArcGIS Maps SDK for Qt 改变视角
arcgis·上位机·地面站·qml·qt6·qt quick·天地图
bug嘛我经常写21 天前
MIKE21结合ArcGIS制作随时间变化的降水文件(.dfs2)-笔记
经验分享·笔记·arcgis
paiooo22 天前
用 XML 保存 LLM 会话得到高可读性会话
arcgis
Q一件事22 天前
ArcGIS中TypeError: can‘t multiply sequence by non-int of type ‘str‘错误
前端·javascript·arcgis
萧行之23 天前
Observable Plot 源码深度解析——1 认识 Observable Plot
arcgis