arcgis api for javascript 4.x 获取当前点击的点/线/图层的信息

通过hitTest()方法可以获取到地图上图层的几何要素

view.on(['click'], function(event) {
	view.hitTest(event).then(function(response) {
		if (response.results.length) {
			var graphic = response.results.filter(function(result) {
				return result.graphic.layer === nodesGraLayer || result.graphic.layer === allPipesGraLayer
			})[0].graphic;

			if (graphic) {
				// 在此操作
				console.log(graphic)
			}
		}
	});
})

发布了17 篇原创文章 · 获赞 43 · 访问量 6万+

猜你喜欢

转载自blog.csdn.net/mf_717714/article/details/100564717