move gmap function from controller to service