0

次のリンクを見て、マップ上のボタンをクリックしてリセット(マップをデフォルトのズーム8に戻す)する方法を教えてください。 http://jsfiddle.net/Behseini/cbTx5/

ありがとう

4

2 に答える 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

于 2012-10-12T22:46:45.317 に答える
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

于 2012-10-14T20:30:39.367 に答える