Select to view content in your preferred language

Arcgis Javascript Application Issue clearing feature layer

4295
3
Jump to solution
04-09-2015 02:59 PM
JohnRitsko
Deactivated User

Ok, here is my issue.  I have a JavaScript application that I have written and the problem comes when I try to hit my home button.  The application uses Feature Layers to show Bus Route and Bus Stops.  If a user has selected a Bus Route on the left and zooms in you can see the highlighted route along with the now highlighted Bus Stops that are associated with this route.  HOME BUTTON function starts my problems.

Issue:  If you are zoomed in enough to see the selected Bus Stops (Green dots) and hit the "HOME" button, only those selected Bus Stops that are visible will be removed and replaced with the Blue Dot Bus Stops. For some weird reason even if you are zoomed out it still doesn't clear all of the feature layer.  I tried putting a timer on the zoomtoextent but that didn't help either.  Anyway, here is my goHome function that may be causing issues.

To replicate issue.  Click on the first route 101 on the left.  Zoom into the lowest portion of the route and you'll see the green selected Stops.  Now hit the home button then zoom back into that area.  Start going North (Up) and you'll see how there are still Selected Stops (Green Dots).

Here is a link to the Application** Link removed as problem is solved **

Sorry tired to put this in a code block but it keeps showing up weird.

//
Resets the Map to its initial state with no routes selected and accordian pane
back to default

    function goHome(){

      // Reset the Accordian Content Panes
and fix naming

      var newTitle = "Bus Arrival Times";

      dijit.byId("pane3").set("title", newTitle);

      var container = dijit.byId("container");

      container.selectChild("RTCBusroutes", true);

     

      // This will remove old values in Bus Arrival Time pane so Bus Arrival Times will clear

      var results = document.getElementById("results");

      var rowCount = results.rows.length;

      for (var x=rowCount-1; x>0; x--)
{

       results.deleteRow(x);

      }

     

      // Removes the Highlight from the currently selected Item in the RTC Bus Routes List pane

      $('.highlight').removeClass('highlight');

     

      // Scrolls to the top of the List in the RTC Bus Routes Content Pane List

      $('#RTCBusroutes').scrollTop(0);

     

      // Remove Currently Selected Bus Routes and Ensure all Routes are showing

      selectedBusRoute.clear();

      busRoutes.setDefinitionExpression("ROUTE IS NOT NULL");

     

      // Remove Currently Selectes Bus Stops and Ensure all Stops are showing

      selectedBusStops.clear();

      busStops.setDefinitionExpression("ROUTE IS NOT NULL");

     

      // Removes Any simpleLineSymbols and Any simplePointSymbols

      map.graphics.clear();

     

      // Closes any open infoWindows

      map.infoWindow.hide();

     

      // Zoom to Map Extent

      map.setExtent(mapExtent);

      //setTimeout(function() {map.setExtent(mapExtent);}, 1000);

     

      // Clears any address entered into Address Search Box

      document.getElementById("search_input").value="";

    }

0 Kudos
1 Solution

Accepted Solutions
TomSellsted
MVP Alum

John,

I looked through your code a bit and it looks like you set the selectedBusStops definition expression, but when you hit the home button, it is only setting the busStop definition expression.  Could that be what is causing them still to display?

Regards,

Tom

View solution in original post

3 Replies
TomSellsted
MVP Alum

John,

I looked through your code a bit and it looks like you set the selectedBusStops definition expression, but when you hit the home button, it is only setting the busStop definition expression.  Could that be what is causing them still to display?

Regards,

Tom

JohnRitsko
Deactivated User

Tom,

You nailed it.  I was using just a selectedBusStop.clear() call thinking that was going to work, when in fact I needed to set the definition expression as well.  It's all good now.  Thanks, I knew I was missing something simple here.

John

0 Kudos
TomSellsted
MVP Alum

John,

Excellent!  I am glad that was it.

Regards,

Tom

0 Kudos