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博客

相关推荐
leaguecn2 天前
ArcGIS授权管理器断网后自动停止
网络·arcgis·授权
咔咔一顿操作2 天前
轻量无依赖!autoviwe 页面自适应组件实战:从安装到源码深度解析
javascript·arcgis·npm·css3·html5
杨超越luckly2 天前
从传统 GIS 向智能/自动化脚本演进:地铁接驳公交识别的 ArcGIS 与 Python 双路径实践
开发语言·arcgis·php·交互·数据可视化
枝上棉蛮4 天前
2026年GIS软件精选:五款工具的专业性与实用性解析
arcgis·gis·qgis·超图·gisbox·地图数据处理·gis工具
激动的兔子4 天前
Arcgis二次开发--评价单元综合限制级别判断矩阵工具
线性代数·arcgis·矩阵
yngsqq4 天前
arcgis 制作图例、视图页面设置
arcgis
规划酱5 天前
Arcgis中pip安装ezdxf部分GIS有pyparsing安装失败的情况处理
python·arcgis·pip·规划酱
奔跑的呱呱牛5 天前
geojson-to-kml (KML 格式转换工具)
arcgis·json
GISer_Jing5 天前
原生HTML项目重构:Vue/React双框架实战
vue.js·人工智能·arcgis·重构·html
智航GIS8 天前
ArcGIS大师之路500技---070对齐边工具
arcgis