简体   繁体   中英

change location to preset coordinates and zoom with click of a button

I have a side panel for my google maps api v3 web app and I would like to add the capability to change to a predefined location and zoom when clicking a button. I am thinking javascript is the answer I am just not certain how to implement. Thank you in advance for your help.

Here's a code snippet:

<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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM