how to get coordinates of the center of the viewed area in google maps using Google Maps JavaScript API v3

Solution 1:

You can call:

map.getCenter();

to return a LatLng object.

Solution 2:

Updated 2018 The below codes are for Google Maps API for Android. In case anyone needs this Script:

double mylat = mGoogleMap.getCameraPosition().target.latitude;               
double mylon = mGoogleMap.getCameraPosition().target.longitude;