Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determining zoom level from single LatLong in Google Maps API

Tags:

google-maps

I'm having some trouble with the Google Maps API; I want to determine a LatLong for a certain place (for example, from the name of a city), then focus my map on it. The LatLong part is working, and so is centering the map on that point. However, I cannot figure out how to determine what a good zoomlevel might be when I only have that single point. I cannot just go to some standard zoomlevel that might look good most of the time, 'cause what happens when the user enters "Russia" instead of "Amsterdam", for example? Some help would be appreciated :)

like image 709
Aistina Avatar asked Nov 23 '08 13:11

Aistina


1 Answers

I just asked this question at Google IO. This feature exists, but is undocumented and doesn't have accessors for it yet. What you want to do is get the Structured Address. Inspect the json structure you get back and look for these new parameters. I'll post more information when I get a chance to try this out.

like image 138
Nick Retallack Avatar answered Oct 12 '22 22:10

Nick Retallack