Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/404.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ArcGIS JS-API,将InfoTemplate添加到现有图形_Javascript_Arcgis Js Api - Fatal编程技术网

Javascript ArcGIS JS-API,将InfoTemplate添加到现有图形

Javascript ArcGIS JS-API,将InfoTemplate添加到现有图形,javascript,arcgis-js-api,Javascript,Arcgis Js Api,如何将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(g

如何将
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);
否则我将覆盖我的对象

任何提示?

只要在图形层实例化后使用图形层上的方法设置模板即可

如果您只想在用户单击图形层时显示信息窗口,则只需在“地图信息窗口”实例上使用show方法即可

this.map.infoWindow.show(e.screenPoint,e.getInfoWindowAnchor(e.screenPoint));
设置内容之后

您还可以使用,它将接受一个延迟(最终返回一个图形数组)

根据用户交互的顺序以及您是否通过网络获取弹出窗口的数据,有很多方法可以实现您想要的功能