简体   繁体   中英

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

You can call:

map.getCenter();

to return a LatLng object.

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM