javascript - ArcGIS JS-API,将 InfoTemplate 添加到现有图形
问题描述
如何infoTemplate
向现有Graphic
实例添加一个?
我正在做这个图形实例,但没有infoTemplate
针对我所拥有的每一点:
const layerMarkers = new GraphicsLayer({id: layerId});
this.map.addLayer(layerMarkers);
// Some code
const graphic = new Graphic(point, imageSymbol, null, null );
layerMarkers.add(graphic);
然后我想在单击图形时调用一些 API:
layerMarkers.on('click', function(e) {
console.log(e);
console.log(this);
//Here I can see the object, I need to do something here with it
});
我需要的是设置:
infoTemplate.setTitle(result.poi.nombre);
infoTemplate.setContent(this.getTooltip(result.poi));
然后我需要用infoTemplate
我不能这样做:
const graphic = new Graphic(point, imageSymbol, null, infoTemplate);
或者我会覆盖我的对象。
有小费吗?
解决方案
只需在图形层已经实例化后,在图形层上使用setInfoTemplate方法设置模板即可。
如果您只想在用户单击图形图层时显示信息窗口,那么只需在地图 InfoWindow 实例上使用 show 方法。
this.map.infoWindow.show(e.screenPoint,e.getInfoWindowAnchor(e.screenPoint));
设置内容后。
您还可以使用setFeatures将采用延迟(最终返回图形数组)
有很多方法可以根据用户交互的顺序以及您是否通过网络获取弹出窗口的数据来执行您想要的操作。
推荐阅读
- php - 同一服务器上的多个 Laravel Horizon
- fuzzy-logic - 模糊逻辑中的混乱 tsukamoto
- python - 如何在 python 中使用数据框的一些列绘制箱线图
- java - AWS Secrets Manager 使用 AWS-SDK Java 更新密钥请求
- kotlin - 模拟异常 - 没有找到答案
- shopify - 如何在shopify网站上进行自动登录?
- excel - 如果系列中的值大于 1000000,则使用宏调整图表的 y 轴
- amazon-web-services - 如何在上传开始和完成时收到通知
- php - PHP:从 IntelliJ 中的接口生成实现
- cassandra - 启动用户态代理时出错:listen tcp 0.0.0.0:9042: bind: address already in use'