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 天前
Node.js 安装指南(Mac 版本)
arcgis
我真的想 啸3 天前
在 Ubuntu 24.04 系统上安装并使用 Codex CLI
linux·ubuntu·arcgis
GIS程序猿4 天前
批量出图工具,如何使用C#实现动态文本
开发语言·arcgis·c#·arcgis插件·gis二次开发
星月前端4 天前
openlayers加载arcgis的VectorTileServer服务图层
arcgis
小飞大王6665 天前
WebSocket技术与心跳检测
前端·javascript·websocket·网络协议·arcgis
( ˶˙⚇˙˶ )୨⚑︎5 天前
如何下载 ArcGIS 官方数据图层
python·arcgis
zhaoyin199410 天前
智能机器人
arcgis
杨超越luckly14 天前
HTML应用指南:利用GET请求获取中国邮政网点位置信息
前端·python·arcgis·html·php·数据可视化
不超限17 天前
ArcGIS JS 异常之:Invalid language tag: RangeError: Invalid language tag:
开发语言·javascript·arcgis
智航GIS18 天前
SHP数据修复
数据库·arcgis