Start New Discussion within our Web Development Community

hi! good day sir.

how can i add a link <a> to body <body> with a function <onclick=""> that change the center of google map.

    <a href="" onClick="myFunction()">location 1</a>

    function myFunction()

You will need to read up on the Google Maps API which can be found here

I believe this is what you will need to do what you mean?

function initialize() {
  var mapOptions = {
    zoom: 4,
    center: new google.maps.LatLng(-25.363882, 131.044922)

  var map = new google.maps.Map(document.getElementById('map-canvas'),

  var marker = new google.maps.Marker({
    position: map.getCenter(),
    map: map,
    title: 'Click to zoom'

  google.maps.event.addListener(map, 'center_changed', function() {
    // 3 seconds after the center of the map has changed, pan back to the
    // marker.
    window.setTimeout(function() {
    }, 3000);

  google.maps.event.addListener(marker, 'click', function() {

google.maps.event.addDomListener(window, 'load', initialize);
This article has been dead for over six months. Start a new discussion instead.