I have a map with a feature class containing airport locations and another feature class showing flight paths between airports. I would like to create a map on ArcGIS Online where when I click on a particular airport, only flight paths from that specific airport are shown. Is there a way of doing this in ArcGIS Online ideally without too much coding? This is a sample of the map in it's present state. I would like to only show the flight routes from specific airports when they are clicked, for example, if I click London, only show flight paths from London. I was having a look through the ArcGIS Online sample code but couldn't find anything with this kind of functionality.
If you want an off-the-shelf option that can achieve this, you should try using ArcGIS Dashboards. In a dashboard, you can configure Layer Actions in your map. For instance, you can set one layer, your lines, to filter based on the values in another layer, your points. Note that this assumes your points and lines to have certain attributes in common.
Consider the following sample dataset. In it, I have Points, with the attribute name, and Lines, with the attributes from_name and to_name. It's not as elaborate as your dataset, but it will do for a demonstration.
- Add you map to a dashboard. You can do this from a blank dashboard, or you can choose the dashboard as an option in the Share menu in the web map viewer.
- Configure the web map element.
- Go to Layer Actions and add a Filter action to the Points layer. Specify that the Lines layer is the target.
- Match the name field from the points layer to the *from_name" field of the Lines layer.
Now go to the map. A feature selection icon has appeared in the upper-left. By turning the selection tool on, you can click on a point to select it, and see the filter in action.
Success! Well, not quite. You may have noticed that we can only specify one field for filtering our lines, and we cannot do an either/or on two fields. Every point in my dataset links to point D, but because D is in the to_name field on several of these, they will get filtered out.
A simple solution to this would be to copy the layer in the webmap, and have the second layer filter on the other field. Alternatively, the lines could be duplicated with the to/from names swapped. Neither is particularly elegant, but the first is certainly less work. Not knowing the structure of your data, I can't speak to your situation specifically.
There are other capabilities in the readymade Web Apps, and in Web App Builder, but the Dashboard's filter may be the closest to what you're looking for that does not require significant coding.