Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en">

<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="initial-scale=1,maximum-scale=1,user-scalable=no" />
  
  <title>Feature Layer Popup Test</title>

  <link rel="stylesheet" href="https://js.arcgis.com/4.28/esri/themes/dark/main.css" />
  <script src="https://js.arcgis.com/4.28/"></script>

  <style>
    html,
    body,
    #viewDiv {
      padding: 0;
      margin: 0;
      height: 100%;
      width: 100%;
    }

    
  </style>
  <script>
    require([
      "esri/Map",
      "esri/views/MapView",
      "esri/layers/FeatureLayer",
      "esri/Basemap",
      "esri/layers/TileLayer",
      "esri/widgets/FeatureTable",
    ], (Map,MapView,FeatureLayer,Basemap,TileLayer,FeatureTable) => {


      const aerial2022 = new Basemap({
        baseLayers: [
        new TileLayer({
          url: "https://www.jfksgis.us/image/rest/services/Aerials/Aerials_2022_cache/MapServer",
          title: "Basemap"
        }),           
        ],
        title: "2022 Aerial",
        visible: true,        
      });

      const parcelLayer = new FeatureLayer({
        url: "https://www.jfksgis.us/server/rest/services/BaseLayers/JFKSBaseMapLayers/MapServer/3",
        title: 'Search Results',
        popupTemplate : createPopupTemplate(),
        listMode: "hide",
        outFields:["*"]
      });

      const theMap = new Map({
          basemap :  aerial2022,
          layers : [parcelLayer] 
      });

      const theView = new MapView({
          container : "viewDiv",
          map : theMap,
          center : [-95.3804157, 39.2315224],
          highlightOptions: {
            color: [64, 247, 244],
            fillOpacity: 0.2,         
          },
          popup: {
            visibleElements: {
              closeButton: true,
            },
            dockEnabled: true,
            dockOptions: {
              autoOpenEnabled: false,
              position: "bottom-right",
              breakpoint: false,
              buttonEnabled: false,          
            },
          },         
      });

      function createPopupTemplate(){
        const urlTax = "https://ks1418.cichosting.com/ttp/tax/Search/search_tax_results.aspx?";
        const urlRC = "https://www.jfksgis.us/prc/"
        var parInfo = 'https://www.jfksgis.us/JFKSParcelSearch/parcelInformation.html';
        var platy = "Replace($feature.Plat_HL, ' ', '%20')"
        return{
          title:
            "<b>Owner:</b> {PartyName_1} " + 
            "<br /><b>Address: </b> {PropertyAddress}" +
            "<br><b>Property Number: </b> {PropertyNumber}" +
            "<br><b>Appraisal:</b> ${RP_AprTot}", 
          outFields: ["*"],
          content:
            [
              {
                type: "fields",
                fieldInfos:[
                  {
                    fieldName: "QuickRefID",
                    label: "Quick Ref ID",
                  },
                  {
                    fieldName: "ACRES",
                    label: "Acres",
                    format:{
                      places: 2,
                    }
                  },                
                ]
              },
              {
                type: "text",
                text: "<a class='hyperlinkURL' target='_blank' href=" + parInfo + "?PropertyID={PropertyID}&PID={PID}&PropNum={PropertyNumber}>Parcel Information</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a class='hyperlinkURL' target='_blank' href=" + urlTax + "PID={PID}>Tax Information</a>"
              },
              {
                type: "text",
                text: "<a class='hyperlinkURL2' target='_blank' href=https://{expression/platlinked}>View Plat</a>&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<a class='hyperlinkURL' href=" + urlRC + "{PropertyNumber}.pdf>Property Record Card</a>", 
              },          
            ],      
            expressionInfos:[
              {
                name: "platlinked",
                expression: platy, 
              },
            ],
            fieldInfos:[{
              fieldName: "RP_AprTot",
              label: "Total Appraised Value",
              format: {
                places: 2,
                digitSeparator: true,
              }         
            },
          ],
        
        }     
      };

      function addButtonToContainer() {
        const isElementLoaded = async selector => {
          while (document.querySelector(selector) === null) {
            await new Promise(resolve => requestAnimationFrame(resolve));
          }
        };
      
        // Wait for the feature menu container to be fully loaded
        isElementLoaded('.esri-popup__main-container').then(() => {
          console.log("Feature menu container loaded");
          let myDiv = document.querySelector('.esri-popup__main-container');
          let button = document.createElement('button5');
          button.innerText = "Print";
          button.style.position = "absolute";
          button.style.top = "5px";
          button.style.right = "5px";
          button.style.zIndex = "9999"; // Set a high z-index value
          button.style.backgroundColor = "white";
          button.style.color = "black";
          button.style.fontWeight = "bold";
          button.style.padding = "3px 3px";
          button.style.cursor = "pointer";
          button.addEventListener("click", printDiv);
          myDiv.appendChild(button);
        });
      }

      function printDiv(){
        const isElementLoaded = async selector => {
          while (document.querySelector(selector) === null) {
            await new Promise(resolve => requestAnimationFrame(resolve));
          }
        }
        isElementLoaded('.esri-popup__main-container').then(() => {
          console.log("Feature menu loaded");

          var printContent = document.querySelector('.esri-popup__main-container').innerHTML;
          const modifiedContent = printContent.replace(/Back/g, '').replace(/Print/g, '').replace(/Owner/g, '<br><br><br>Owner');
          printWindow = window.open('', '_blank');
          printWindow.document.write(modifiedContent);
          printWindow.document.close();
          // Wait for a short period before printing
          setTimeout(function() {
            printWindow.print();
          }, 100);
          
        })  
      };
      
      const featureTable = new FeatureTable({
        label: "Table",
        view: theView,
        layer: parcelLayer,
        highlightOnRowSelectEnabled: true,
        highlightEnabled: true, 
        //multiSortEnabled: true,
        visibleElements: {
            selectionColumn: false,
            columnMenus: false, 
            //menu:false,
            menuItems:{
                refreshData: false,
            }
        },
        tableTemplate: { // autocastable to TableTemplate
          // The table template's columnTemplates are used to determine which attributes are shown in the table
          columnTemplates: [ // Array of either FieldColumnTemplates or GroupColumnTemplates
            { // autocastable to FieldColumnTemplate
                type: "field",
                fieldName: "PartyName",
                label: "Name",
                //maxLength: 1,
                direction: "desc",
                format:{
                    digitSeparator: false,
                }
            },
            {
                type: "field",
                fieldName: "QuickRefID",
                label: "QuickRef",
            },
          ]
        },
        container: document.getElementById("tableDiv")
      });
      

      let query = parcelLayer.createQuery();
      query.where = "PartyName_1 LIKE '%driscoll%'";
      query.outFields = [ "*" ];

      parcelLayer.queryFeatures(query)
        .then(function(response) {
          // Open the popup with the queried features
          theView.openPopup({
            features: response.features,
            featureMenuOpen: true,
            featuresPerPage: 100,
          });
          addButtonToContainer();
          if(response.features.length === 0){
                alert("Search query found no results.");
                return
            }else{
              for(let iii=0; iii < response.features.length; iii++){
                //console.log(response.features[iii])
                //featureTable.selectRows(response.features[iii]);
                featureTable.highlightIds.add(response.features[iii].attributes.OBJECTID);
                console.log(featureTable.highlightIds.add(response.features[iii].attributes.OBJECTID))
                featureTable.filterBySelection();
              }
            };
        });

    });
  </script>
</head>

<body>
  <div id="viewDiv"></div>
 
  <div id="tableDiv"></div>
 
</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

              
                
              
            
!
999px

Console