Refactores search and map display code depending on format