AnsweredAssumed Answered

Line in Feature Layer is 'stuck' after viewing Popup?

Question asked by zaloudek on Apr 1, 2016
Latest reply on Apr 1, 2016 by zaloudek

I have two feature layers in my map.  I have separate info templates defined and assigned to each.  One feature layer is of contiguous polygons (counties), so clicking on one to show the info window popup is not difficult for the user. However, the other feature layer is lines, which requires some precision to click and see the info window popup. So, I added some code to create a buffer extent around the clicked map point.  However, I think this workaround had an unintended consequence. 

 

In addition to viewing the lines, I also have a few options (radio buttons, etc) on the side, so the user can filter which lines are viewed.  This is accomplished by having a ‘refresh’ function that runs when one of the filter options are used.  It calculates a definition query and assigns it to the lines feature layer.

 

My problem occurs when the user clicks a line (showing the popup), and then sets one of the filter options.  The line with the current popup gets ‘stuck’, and will show even if it does not match the definition query.  Once the user clicks on a different line, or on the map, then the problem line disappears. Any ideas as to what causes the line to be ‘stuck’ on?  Is it a graphic thing?

 

Here are the parts of my code that I think are relevant.  First the buffer & map onclick functions:

// Buffer function
function pointToExtent (map, point, toleranceInPixel) {
     var pixelWidth = map.extent.getWidth() / map.width;
     var toleranceInMapCoords = toleranceInPixel * pixelWidth;
     return new Extent(point.x - toleranceInMapCoords,
                    point.y - toleranceInMapCoords,
                    point.x + toleranceInMapCoords,
                    point.y + toleranceInMapCoords,
                    map.spatialReference);
}
                    
// Set up feature layer popups (to include buffer for tracks)
var query = new Query();
map.on("click", function (event) {
     if (rdo1.checked == true)  {
          query.geometry = pointToExtent(map, event.mapPoint, 8);
          var deferred = flyrTracks.selectFeatures(query, FeatureLayer.SELECTION_NEW); }
     else if (rdo2.checked == true)  {
          query.geometry = pointToExtent(map, event.mapPoint, 1);
          var deferred = flyrCounties.selectFeatures(query, FeatureLayer.SELECTION_NEW); }
     map.infoWindow.setFeatures([deferred]);
     map.infoWindow.show(event.mapPoint);
});

 

And the refresh function that runs to filter the lines:

function refresh()  {
     map.infoWindow.hide();
     // SET UP defquery STRING HERE
     flyrTracks.setDefinitionExpression(defquery);
     flyrTracks.redraw();
}

Outcomes