简体   繁体   中英

Google Maps Javascript API view location

I'm using Google Maps Javascript Web API. I'm looking to get the current location (GPS coordinates) of the view. Meaning, if I drag the map all the way to England, the function would return the GPS coordinates of the view's center (which would be somewhere in England).

How can it be accomplished? Is there a certain function I can use?

Try getCenter() :

let map = new google.maps.Map(document.getElementById('map'), { ... }),
    currentLocation = map.getCenter();

Demo

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