add innerHTML within title of popuptemplate (arcgis-js-api 4.xx)

限于喜欢 提交于 2020-07-10 10:26:13

问题


I have tried it stand alone like this:

myLayer.popupTemplate = { <---  have also tried defining this as popupShake
      title: function(feature) {
          let spl = document.createElement("span");
          spl.className = "name_plc";
          spl.innerHTML = "<span class='name_plc'></span>";

          return spl;
      }
    };

I have also tried it inline within the popuptemplate call (such as the content section, but title will not run even though documentation states it accepts strings and OR functions).

i.e.

         let popupShake = {
            outFields: ["*"],
           "title": function (feature){ <------------- breaks popup, but content below works
                let spl = document.createElement("span");
                spl.className = "name_plc";
                dlv.innerHTML = "<span class='name_plc'></span>";

                return spl;
           },
           "content": function (feature){
             let name_plc;
             let dlv = document.createElement("div");
             dlv.className = "popd";
             dlv.innerHTML = `<b><span class='name_plc'></span></b><br>ID: <span class="ida">${feature.graphic.attributes.id}</span><br> URL: <a href="${feature.graphic.attributes.url}" target="_blank">View</a> <br> Updated: ${feature.graphic.attributes.updated} <br>Grid_value: ${feature.graphic.attributes.grid_value}<br> Event Time: ${feature.graphic.attributes.eventTime}`;
              
             setTimeout(() => {
                getName();
             }, 20);
             ................

来源:https://stackoverflow.com/questions/62819295/add-innerhtml-within-title-of-popuptemplate-arcgis-js-api-4-xx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!