Geographic Information Systems Asked on January 4, 2021
I’ve buildt a halfly harcoded popup builder widget, but i don’t know how to push fields from relationships into my popup div. I know how to do it in the ObjOriented way, but it’s not right for me.
Example:
var popupTemplate = new PopupTemplate({
"title": "Beverly Hills Trees By Block",
"fieldInfos": [{
"fieldName": "Point_Count",
"label": "Count of Points",
"format": {
"places": 0,
"digitSeparator": true
}
}, {
"fieldName": "relationships/0/Point_Count_COMMON",
"label": "Sum of species tree count",
"format": {
"places": 0,
"digitSeparator": true
},
I show my scructure: first function creates the popup content div, the second calls it, if i want popup.
But i couldnt find the documentation, how to get a graphic’s relationships, i can only get the attributes.
Any idea?
function _getPopupTextContent(graphic) {
let popupContent = ""
popupContent += "<div style='padding:5px;background-color:rgb(251,183,46)'><b>" +
"</b></div>" +
"<table style='width:100%;'>"
console.log(graphic)
//popupContent += "<tr>"+graphic.attributes["relationships/1/FIELD"]+"</tr>" not working //undefined
for (var property in graphic.attributes){
console.log((property.toString()).split(/[.]/))
var dbName = (property.toString()).split(/[.]/)[1]
if (dbName !== undefined){
var dbTableName = dbName.split(/[_]/)[3];
//console.log(maximoTableName)
var fieldName = (property.toString()).split(/[.]/)[2];
let value = graphic.attributes["DB.DB_ESRI_V_"+dbTableName+"_TT."+fieldName]
if(fieldName == 'FIELDNAME1'&& value !== undefined){
popupContent += "<tbody><tr><td id = 'attrtd'><b>Label</b></td><td id = 'attrtd''>" +
value
}
if(fieldName == 'FIELDNAME2'&& value !== undefined){
popupContent += "<tr><td id = 'attrtd'><b>Label</b></td><td id = 'attrtd''>" +
value
}
if(fieldName == 'FIELDNAME3'){
popupContent += "<tr><td id = 'attrtd'><b>Label</b></td><td id = 'attrtd''>" +
value
}
if(fieldName == 'FIELDNAME4'&& value !== undefined){
popupContent += "<tr><td id = 'attrtd'><b>Label</b></td><td id = 'attrtd''>" +
value
}
}
popupContent += "</td></tr>" +
"</td></tr>" +
"</a></td></tr>" +
"</tbody></table>"
return popupContent;
}
function _joinAndCreateInfoTemplate(){
var mainLayer = _getWebmapOperationalLayerById(subStationLyrId);
for(var title in popupSubIdDict){
var popupName = _removeAccents(title).toLowerCase(); // subLayertitle
var subId = popupSubIdDict[title]; //sub id
mainLayer.getLayerObject().then(function (subLyrObj) {
if (popupName == 'sublayer'){
popupName = new InfoTemplate();
popupName.setTitle(title);
popupName.setContent(_getPopupTextContent);
}
subLyrObj.infoTemplates[subId] = {
infoTemplate: new InfoTemplate(popupName)
};
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP