In the era of globalization, the rapid development of mobile technologies has shown the emergence of new forms of group formation. Groups formed of people connected by certain social relationships can be easily set up by online social networks. Additionally, the geographical locations of online users have become an important feature for the group formation. Accordingly, we proposed an algorithm to search of an optimal group formation based on users' location of latitude and longitude coordinates from the map using a heuristic search algorithm named Genetic algorithm (GA). The main object of the proposed algorithm is to arrange people with dissimilar positions into proper groups to have a mean distance between members within a group as short as possible. Furthermore, an empirical performance comparison of previous greedy and GAbased algorithms by simulation results is presented to verify the efficiency of the proposed algorithm.