When a filter is set on the provided data set, includeLayer will be set to false on the current record of the loop. Location is used in both the if & else if part of the statement, but its only set in the if so the indexKey will continuously be set to the last included record's key. This will incorrectly remove the last valid layer from the layers object.
When a filter is set on the provided data set, includeLayer will be set to false on the current record of the loop. Location is used in both the if & else if part of the statement, but its only set in the if so the indexKey will continuously be set to the last included record's key. This will incorrectly remove the last valid layer from the layers object.