Fix JS error when path layer is not on map