undefined layer[0] due to empty $viewport.find(".current-map-layer")