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

JavascriptGoogle Maps-Api-3

Javascript Problem Overview


How to get coordinates using javascript Google Maps JavaScript API v3 of the center of the currently viewed area on google maps? Thanks

Javascript Solutions


Solution 1 - Javascript

You can call:

map.getCenter();

to return a LatLng object.

Solution 2 - Javascript

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;

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionStewie GriffinView Question on Stackoverflow
Solution 1 - JavascriptMike JeffreyView Answer on Stackoverflow
Solution 2 - JavascriptyehyattView Answer on Stackoverflow