<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Dynamically updating Pop-up with Time Extent in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamically-updating-pop-up-with-time-extent/m-p/1095082#M74542</link>
    <description>&lt;P&gt;I'm not sure exactly where on the Esri community this question should go, but does anyone know if it's possible to create dynamic pop-ups based on time extent?&lt;/P&gt;&lt;P&gt;I am creating a web application with javascript and I know how to create statistics that change based on time extent using timeSlider.watch. I used this to create an information panel with statistics that change based on the time extent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For context for the project, I have a feature layer of points with beginning and end times and a layer with county boundaries (no time data). I would like to create a pop-up that says:&lt;/P&gt;&lt;P&gt;"Between {startYear} and {endYear} there were {points that intersect county} in {county} county."&lt;/P&gt;&lt;P&gt;I have gotten this far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  // county boundary feature layer
  var county = new FeatureLayer({
    portalItem: {
      id: "ba98baef19d447ca83fb2084c396acde"    
    },
    outFields: ["*"],
    minScale: 0,
    maxScale: 0,
    popupTemplate: {
      title: "{Name} County",
      content: queryWellCounts
    }
  });

  ///// Pop up function

  var queryWellsTask = new QueryTask({
    url: "https://services.arcgis.com/ZzrwjTRez6FJiOq4/arcgis/rest/services/OGHistory/FeatureServer/0"
  });

  function queryWellCounts(target) {
    var counts = new StatisticDefinition({
      statisticType: "count",
      onStatisticField: "API",
      outStatisticFieldName: "count_county"
    });
    var query = new Query({
      geometry: target.graphic.geometry,
      outFields: ["*"],
      spatialRelationship: "intersects",
      timeExtent: timeSlider.timeExtent,
      outStatistics: [counts]
    });

    var yearOnly = {year:'numeric'}; //set to show year only in date strings 

    return queryWellsTask.execute(query).then(function(result) {
      var stats = result.features[0].attributes;
      if (stats.count_county==1) {
        return (
        "Between " +
        "&amp;lt;b&amp;gt;" +
        timeSlider.timeExtent.start.toLocaleDateString("en-us",yearOnly) + 
        "&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;" +
        timeSlider.timeExtent.end.toLocaleDateString("en-us",yearOnly) +
        "&amp;lt;/b&amp;gt; there was " +
         "&amp;lt;b&amp;gt;" + 
         stats.count_county +
          "&amp;lt;/b&amp;gt;" +
          " well in {NAME} County.") 
      }else{ 
        return(
          "Between " +
          "&amp;lt;b&amp;gt;" +
          timeSlider.timeExtent.start.toLocaleDateString("en-us",yearOnly) + 
          "&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;" +
          timeSlider.timeExtent.end.toLocaleDateString("en-us",yearOnly) +
          "&amp;lt;/b&amp;gt; there were " +
           "&amp;lt;b&amp;gt;" + 
           stats.count_county +
            "&amp;lt;/b&amp;gt;" +
            " wells in {NAME} County." )
      }
    });
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works well if the time slider is paused and you click on a county. It shows the correct amount of wells for that county for the current time extent. I would like it to dynamically change as the slider moves (as an info panel I have does), so I'm thinking I need to add timeslider.watch() in the function, but I'm still new to this and am struggling to figure out how that works.&lt;/P&gt;&lt;P&gt;I know how to do it with filtering and featurelayer/featureLayerViews, but not with queries. Can it be done or should I be rethinking how to get the query for the pop-up?&lt;/P&gt;&lt;P&gt;On another note, if I can't get the information within the pop-up to 'watch' the time slider, is there a way for me to 'force close' the pop-ups when someone hits 'play' on the time slider. A bit annoying to the user, but kind of circumvents my issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance is much appreciated.&lt;/P&gt;&lt;P&gt;Here's the &lt;A href="https://cschooley95.github.io/" target="_self"&gt;link to the site&lt;/A&gt; if you want to look at it.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 02 Sep 2021 21:17:12 GMT</pubDate>
    <dc:creator>cschooley</dc:creator>
    <dc:date>2021-09-02T21:17:12Z</dc:date>
    <item>
      <title>Dynamically updating Pop-up with Time Extent</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamically-updating-pop-up-with-time-extent/m-p/1095082#M74542</link>
      <description>&lt;P&gt;I'm not sure exactly where on the Esri community this question should go, but does anyone know if it's possible to create dynamic pop-ups based on time extent?&lt;/P&gt;&lt;P&gt;I am creating a web application with javascript and I know how to create statistics that change based on time extent using timeSlider.watch. I used this to create an information panel with statistics that change based on the time extent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;For context for the project, I have a feature layer of points with beginning and end times and a layer with county boundaries (no time data). I would like to create a pop-up that says:&lt;/P&gt;&lt;P&gt;"Between {startYear} and {endYear} there were {points that intersect county} in {county} county."&lt;/P&gt;&lt;P&gt;I have gotten this far:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  // county boundary feature layer
  var county = new FeatureLayer({
    portalItem: {
      id: "ba98baef19d447ca83fb2084c396acde"    
    },
    outFields: ["*"],
    minScale: 0,
    maxScale: 0,
    popupTemplate: {
      title: "{Name} County",
      content: queryWellCounts
    }
  });

  ///// Pop up function

  var queryWellsTask = new QueryTask({
    url: "https://services.arcgis.com/ZzrwjTRez6FJiOq4/arcgis/rest/services/OGHistory/FeatureServer/0"
  });

  function queryWellCounts(target) {
    var counts = new StatisticDefinition({
      statisticType: "count",
      onStatisticField: "API",
      outStatisticFieldName: "count_county"
    });
    var query = new Query({
      geometry: target.graphic.geometry,
      outFields: ["*"],
      spatialRelationship: "intersects",
      timeExtent: timeSlider.timeExtent,
      outStatistics: [counts]
    });

    var yearOnly = {year:'numeric'}; //set to show year only in date strings 

    return queryWellsTask.execute(query).then(function(result) {
      var stats = result.features[0].attributes;
      if (stats.count_county==1) {
        return (
        "Between " +
        "&amp;lt;b&amp;gt;" +
        timeSlider.timeExtent.start.toLocaleDateString("en-us",yearOnly) + 
        "&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;" +
        timeSlider.timeExtent.end.toLocaleDateString("en-us",yearOnly) +
        "&amp;lt;/b&amp;gt; there was " +
         "&amp;lt;b&amp;gt;" + 
         stats.count_county +
          "&amp;lt;/b&amp;gt;" +
          " well in {NAME} County.") 
      }else{ 
        return(
          "Between " +
          "&amp;lt;b&amp;gt;" +
          timeSlider.timeExtent.start.toLocaleDateString("en-us",yearOnly) + 
          "&amp;lt;/b&amp;gt; and &amp;lt;b&amp;gt;" +
          timeSlider.timeExtent.end.toLocaleDateString("en-us",yearOnly) +
          "&amp;lt;/b&amp;gt; there were " +
           "&amp;lt;b&amp;gt;" + 
           stats.count_county +
            "&amp;lt;/b&amp;gt;" +
            " wells in {NAME} County." )
      }
    });
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works well if the time slider is paused and you click on a county. It shows the correct amount of wells for that county for the current time extent. I would like it to dynamically change as the slider moves (as an info panel I have does), so I'm thinking I need to add timeslider.watch() in the function, but I'm still new to this and am struggling to figure out how that works.&lt;/P&gt;&lt;P&gt;I know how to do it with filtering and featurelayer/featureLayerViews, but not with queries. Can it be done or should I be rethinking how to get the query for the pop-up?&lt;/P&gt;&lt;P&gt;On another note, if I can't get the information within the pop-up to 'watch' the time slider, is there a way for me to 'force close' the pop-ups when someone hits 'play' on the time slider. A bit annoying to the user, but kind of circumvents my issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance is much appreciated.&lt;/P&gt;&lt;P&gt;Here's the &lt;A href="https://cschooley95.github.io/" target="_self"&gt;link to the site&lt;/A&gt; if you want to look at it.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 Sep 2021 21:17:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/dynamically-updating-pop-up-with-time-extent/m-p/1095082#M74542</guid>
      <dc:creator>cschooley</dc:creator>
      <dc:date>2021-09-02T21:17:12Z</dc:date>
    </item>
  </channel>
</rss>

