Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 755
Stewie Griffin Avatar asked Mar 21 '12 18:03

Stewie Griffin


People also ask

How do you punch coordinates into Google Maps?

Enter Coordinates on Android Open Google Maps, enter the coordinates into the Search box at the top, and hit the Search key on the keyboard. You'll see a pin appear on the map for the spot. Swipe up from the bottom to get directions or view details for the location.


2 Answers

You can call:

map.getCenter(); 

to return a LatLng object.

like image 76
Mike Jeffrey Avatar answered Sep 21 '22 17:09

Mike Jeffrey


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; 
like image 44
yehyatt Avatar answered Sep 20 '22 17:09

yehyatt