Refactor setting of latitude and longitude into named callback function