user2298995
user2298995

Reputation: 2173

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?

Upvotes: 0

Views: 162

Answers (1)

DontVoteMeDown
DontVoteMeDown

Reputation: 21475

Try getCenter():

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

Demo

Upvotes: 1

Related Questions