Ken*_*oto 2 javascript event-handling angularjs arcgis-js-api
I am using the ArcGIS JavaScript API 4.0 in order to display manholes for a given area. I am using our GIS Service to generate a feature layer. However, all the associated photos for that manhole has to be queried independently. My thought was to find an event handler for when the pop up opens and then somehow query the database for those photos and dynamically place the links in the popup template object. Here are the problems:
Here is the event handler for when user clicks on the map
view.on("click", function(evt){
console.log("test pop up handler");
});
Run Code Online (Sandbox Code Playgroud)
There are event handlers for when the feature layer is added and for action on the pop up. Here is the pop up template I need to add dynamic media:
var manholeTemplate = new PopupTemplate({
title: 'Smoke : {Label}',
content:
[{
type:"media",
mediaInfos: [{
title: "<b> Related Photos </b>",
type: "image",
value:{
sourceURL: "https://xxxxx.xxxx.getPhoto.php?id=09fsgfsfgE"
}
}]
}]
});
Run Code Online (Sandbox Code Playgroud)
使用监视属性功能监视“view.popup.visible”属性。
弹出窗口打开后,您可以使用popup.features 获取弹出窗口指向的功能
您可以在sourceURL字符串中的大括号内使用属性名称,API 将根据单击的属性自动获取 url。
一个示例地图在这里展示了以上三项(打开浏览器控制台,然后点击一个功能):https : //jsfiddle.net/gavinr/1jLmfLLL/