I was just trying to figure this out and realized the easiest way was to enter iTunes -> iPhone -> Info Tab -> Check Sync Contacts with Google Contacts
Enter your Gmail account info. A message box will appear with Merge or Replace. I just clicked on Merge.
Hit Apply and all my contacts from my iPhone was synced to Gmail.