0

Can you please take a look at following link and let me know how I can reset (Return Map to default Zoom 8) by clicking a button on the Map? http://jsfiddle.net/Behseini/cbTx5/

Thanks

2 Answers 2

2

You need to move the map variable outside initialize and call map.setZoom(zoo). Here is a fiddle demonstrating this: http://jsfiddle.net/cbTx5/2/

Edit - fixed the demo

Sign up to request clarification or add additional context in comments.

Comments

1

The map will change the zoom level when the zoom_changed event is triggered. When you call setZoom(value) this event is triggered automatically.

If you want to have more control over when this happens you can always say:

$('.classname').click(function(){ map.zoom=8; google.maps.event.trigger(map, 'zoom_changed'); });​ 

which will have the same effect and is less elegant, but it gives a better overview as to what is happening.

For all the events that are triggered when the map is manipulated, check out this demo: http://gmaps-samples-v3.googlecode.com/svn/trunk/map_events/map_events.html

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.