0

I have created one small application, where user can store his/her contacts with full address including map. Therefore I am using the Google Maps API, where user can point out his/her address. For this I have given address fields with Country, State and City. When user entered this information, I am showing the default address on Google Maps, then the user has to drag the marker/pointer onto his/her exact location. Now, in this case I want the zoom level of googles map to be set as per location's population. This means if the user entered city with no mans land (less population or any desert place or any jungle place or very small area on city then zoom level should be more, so user can see proper area on map) otherwise zoom level should be less.

Can some one guide me how to do this?

MageJohn
  • 127
  • 2
  • 7
Manish Sapkal
  • 5,591
  • 8
  • 45
  • 74

2 Answers2

0

This won't be possible using the Google API's alone, (I'm unsure if demographics info has been released for the US, I know it was in the works, but it certainly won't work elsewhere). You will have to find an external source to provide your demographics information for you.

The Google API's do not keep a public record of population density.

You could however be a but more tricksy and use an approximation. You could for example do a places search in the area (using an arbitrary radius), count the number of results and use this to set your zoom level (again using an arbitrary value to determine high/medium/low etc). It's a fair assumption (though still an assumption) that any area with a large number of 'places' returned will be densely populated.

ChrisSwires
  • 2,713
  • 1
  • 15
  • 28
  • thanks @Swires. My main goal is that, user can just see its entered address clearly on the map. If i am setting zoom level to 14, some time it does not saw country name also, because My map area is very small on page (width:445px, 162px height) – Manish Sapkal Jan 27 '14 at 12:32
  • I don't think this is a viable solution and it seems over complicated. – MrUpsidown Jan 27 '14 at 13:26
0

You don't need to base this on the population of the location. Please check the follwing link. I think it should give you an idea of the options you have.

Google Maps API v3 - Geocoder results issue with bounds

Check both my question and my answer. You will probably want to use the viewport object.

Community
  • 1
  • 1
MrUpsidown
  • 21,592
  • 15
  • 77
  • 131