Javascript 将位置更改为预设坐标,并单击按钮进行缩放

Javascript 将位置更改为预设坐标,并单击按钮进行缩放,javascript,google-maps-api-3,Javascript,Google Maps Api 3,我的google maps api v3 web应用程序有一个侧面板,我想添加一个功能,可以在单击按钮时更改到预定义的位置并进行缩放。我认为javascript是我不确定如何实现的答案。提前感谢您的帮助。这里有一段代码片段: <script> function ZoomAndCenter() { map.setCenter(new google.maps.LatLng(-34.397, 150.644)); map.setZoom(15); } </script>

我的google maps api v3 web应用程序有一个侧面板,我想添加一个功能,可以在单击按钮时更改到预定义的位置并进行缩放。我认为javascript是我不确定如何实现的答案。提前感谢您的帮助。

这里有一段代码片段:

<script>
function ZoomAndCenter() {
  map.setCenter(new google.maps.LatLng(-34.397, 150.644));
  map.setZoom(15);
}
</script>
<a href="javascript:ZoomAndCenter()">Move to location</a>

函数ZoomAndCenter(){
map.setCenter(新的google.maps.LatLng(-34.397150.644));
map.setZoom(15);
}
以下是一段代码片段:

<script>
function ZoomAndCenter() {
  map.setCenter(new google.maps.LatLng(-34.397, 150.644));
  map.setZoom(15);
}
</script>
<a href="javascript:ZoomAndCenter()">Move to location</a>

函数ZoomAndCenter(){
map.setCenter(新的google.maps.LatLng(-34.397150.644));
map.setZoom(15);
}

这正是我想要的。非常感谢。这正是我想要的。非常感谢。