Reputation: 1180
I'm hoping to use a Google Map in this way: User zooms in on the location they want (using either pan & zoom or a search bar above the map) and the coordinates of the center of the map are passed down to my PHP script as either "$lat" & "$lon" OR "$coords". If someone could find or write some code that does this I'd be elated... Let me know if more info is needed... My understanding of JavaScript (and even PHP) is limited so please try to be as complete as you can :)
Upvotes: 0
Views: 1119
Reputation: 6597
So, this is going to be problematic (and virtually impossible) because the PHP code is executed server side, before the page finishes loading in the client's browser. Javascript is executed "live" as the user does things in the browser, so there really isn't an easy straightforward way to push from JS to PHP.
To properly answer the question we need to know what you want to do with the coordinate data, and where this is the whole "framework" in your app, ex:
You have a few options (ordered simplest to hardest)
Since you asked, you can get the map's center location by doing map.getCenter()
, which returns a lat/lon pair
Upvotes: 1