Behseini
Behseini

Reputation: 6330

Accessing and Setting Map Options (Zoom)

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

Upvotes: 0

Views: 217

Answers (2)

kaskader
kaskader

Reputation: 1972

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

Upvotes: 1

Laurence
Laurence

Reputation: 1713

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

Upvotes: 2

Related Questions