Do I need to put a link in my Google Maps

I have a map on my website, where the location of the establishment on the map has the logo, instead of the default PIN of Google Maps, a PNG image appears.

I need that image, upon clicking, to lead to a specific URL, within the site itself. I've searched a few codes, but it didn't work out.

Follows my code used on the site:

    <script>

// This example adds a marker to indicate the position of Bondi Beach in Sydney,
// Australia.

function initMap() {
  var map = new google.maps.Map(document.getElementById('map'), {
    zoom: 18,
    center: {lat: -27.6041949, lng: -48.466012}
  });


  var image = 'img/marcador.png';
  var beachMarker = new google.maps.Marker({
    position: {lat: -27.6041949, lng: -48.466012},
    map: map,
    icon: image
  });
}

    </script>
    <script async defer
        src="https://maps.googleapis.com/maps/api/js?key=AQUI_VAI_O_MEU_API_&signed_in=true&callback=initMap"></script>

 <style>
     #map {
        height: 432px;
      }
    </style>

From now on I thank everyone for their cooperation!

Author: Alessandro Ramos, 2016-09-19

1 answers

Try adding a listener to the click event on marker as in the example below. Using the window.location property you will be able to redirect to a path within the site.

beachMarker.addListener('click', function() {
  window.location = '/index.html';
});

Information about Google Maps API Markers in this link .

 1
Author: Lucas Fontes Gaspareto, 2016-09-20 15:01:50