autozoom depending upon the location provided

265 views
Skip to first unread message

Rajan Maharjan

unread,
Jun 19, 2012, 12:01:01 AM6/19/12
to google-map...@googlegroups.com
Hello group,
I wanted to know if there is some method to get the map autozoom depending upon the information provided.

Like if we provide street name and address than it will zoom to level 15 and if we give country name than it should have zoom to 10 with marker being pointed as google map does.

Thanks in advance

geoco...@gmail.com

unread,
Jun 19, 2012, 12:12:31 AM6/19/12
to Google Maps JavaScript API v3
You can use the geocoder to center and zoom the map to the area that
google provides in the geocoder result (the viewport)

Here is an example that does it for US states:
http://geocodezip.com/v3_zoom2stateSelectList.html

if you want to specify your own zoom level for particular classes of
information, you can do that (if you can use the information in the
result returned by google to determine which value to use)

-- Larry

Rajan Maharjan

unread,
Jun 19, 2012, 12:28:51 AM6/19/12
to google-map...@googlegroups.com
Thank you soo much for the comment
I would love to see the direct code working. In the example you send me there is just state. I want something like 
where you can enter the address and would make different zoom level depending upon the address information you provide like google does

Once again thanks a lot

Regards
Rajan Maharjan

geoco...@gmail.com

unread,
Jun 19, 2012, 1:38:06 AM6/19/12
to Google Maps JavaScript API v3
On Jun 18, 9:28 pm, Rajan Maharjan <friendship.ra...@gmail.com> wrote:
> Thank you soo much for the comment
> I would love to see the direct code working. In the example you send me
> there is just state. I want something like

http://rajanmaharjan.com.np/autozoom.php

I get a javascript error on that page (the codeLatLng function is not
defined).

> where you can enter the address and would make different zoom level
> depending upon the address information you provide like google does

Did you view the source of my example? The example fixes the input
string to the geocoder, but does what you want with the result.

-- Larry

Rajan Maharjan

unread,
Jun 19, 2012, 2:05:46 AM6/19/12
to google-map...@googlegroups.com
I look on your source code but seems like you have fixed zoom level. What I am trying to find is
If someone try to search country than zoomlevel should be accordingly so that the map of country can be seen
And if someone is trying to search for street than zoom level should be in such order that street can be seen clearly. This can be seen in maps.google.com by entering "United States" and than again making search with "New york, United States"

My current page works fine  http://rajanmaharjan.com.np/autozoom.php  has no such error as mentioned. I tried in chrome and mozilla.

Can you please spend some more time to guide me through. It would be of more helpful. Many Many thanks in advance Mr. Larry

geoco...@gmail.com

unread,
Jun 19, 2012, 2:13:55 AM6/19/12
to Google Maps JavaScript API v3
On Jun 18, 11:05 pm, Rajan Maharjan <friendship.ra...@gmail.com>
wrote:
> I look on your source code but seems like you have fixed zoom level.

No, the zoom is not fixed. The example zooms to the bounds of the
result from the geocoder. Compare the zoom for California and New
Jersey.

> What I am trying to find is If someone try to search country than zoomlevel
> should be accordingly so that the map of country can be seen

That is what that example does. Here is a similar one for countries:
http://geocodezip.com/v3_zoom2countrySelectList.html

> And if someone is trying to search for street than zoom level should be in
> such order that street can be seen clearly. This can be seen in
> maps.google.com by entering "United States" and than again making search
> with "New york, United States"
>
> My current page works fine  http://rajanmaharjan.com.np/autozoom.php has
> no such error as mentioned. I tried in chrome and mozilla.

Try Ctrl-Shift-J for the console, I still get the error.

Rossko

unread,
Jun 19, 2012, 4:58:05 AM6/19/12
to Google Maps JavaScript API v3
> My current page works fine  http://rajanmaharjan.com.np/autozoom.php has
> no such error as mentioned.

Breaks for me, when the marker is dragged. 'codeLatLng' is undefined
Look in your code for drag end.

Rajan Maharjan

unread,
Jun 19, 2012, 5:30:01 AM6/19/12
to google-map...@googlegroups.com
Thank you Rossko for the feedback. I didnt noticed that.
I just wanted to have the autozoom according to the accuracy of information provided and currently i am able to make auto zoom of google map depending upon the accuracy of information provided by user.

And thank you Larry for your help
Reply all
Reply to author
Forward
0 new messages