arcgis for js 3.3 点击地图图标,弹出信息层弹窗
低吗如下:
1.创建图层
function create_disaster(layerId){
let mapLayer = map.getLayer(layerId);
if(!mapLayer){
mapLayer = new esri.layers.GraphicsLayer({
id: layerId
});
map.addLayer(mapLayer);
mapLayer.on("click", clickFn);
}
return mapLayer;
}
2.信息弹窗
function clickFn(e){
require([
"esri/Color", "esri/InfoTemplate"
], function( Color, InfoTemplate) {
var infoTemplate = new InfoTemplate();
infoTemplate.setTitle(e.graphic.attributes.data.title); //信息弹窗标题
infoTemplate.setContent("<p>经度:"+e.graphic.attributes.data.lon+"</p><p>经度:"+e.graphic.attributes.data.lat+"</p>"); //信息弹窗内容
e.graphic.setInfoTemplate(infoTemplate);
});
}