How do I direct the google bookmark to a page?

Asked

Viewed 42 times

1

I manage to implement a google bookmark, and also manage to implement a link in the bookmark, when the user clicks on the bookmark it is automatically directed to another page, the only problem that when the user clicks on the marker is the component that will be directed to another page and not the site that goes to another page, note the two figures below;

Figure 1.

inserir a descrição da imagem aqui

Figure 2.

inserir a descrição da imagem aqui

So as you can see when the user clicks on the marker instead of the entire page being rendered to another page it just renders the internal component.

Is there any way in Javascript code to be able to render the entire page to be directed to another page instead of the internal component?

This is my code:

<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta charset="utf-8">
    <title>Simple markers</title>
    <style>
      html, body {
        height: 100%;
        margin: 0;
        padding: 0;
      }
      #map {
        height: 100%;
      }
    </style>
   <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAZBoBe3ObpfsAiLNq2aByZXKp4XRlUPYE" type="text/javascript"></script> 
  </head>
  <body>

    <script>

function initialize() {

  var myLatLng = {lat: -23.6336946, lng: -46.73667330000001};
  var mapOptions = {
    zoom:15,
    center:myLatLng
  }

  var map = new google.maps.Map(document.getElementById('map'), mapOptions);



  var marker = new google.maps.Marker({
    position: myLatLng,
    map: map,
    title: 'MDW Outsoucing Consultoria'
  });
/*
  var beachMarker = new google.maps.Marker({
    position: {lat: -27.6041949, lng: -48.466012},
    map: map,
    icon: image
  });
  */

  marker.addListener('click', function() {
  window.location = 'https://www.mdwoutsourcing.com.br/quem-somos';
});

}

google.maps.event.addDomListener(window, 'load', initialize);

    </script>
    <div id="map"></div>
  </body>
</html>
  • have tried window.top.location in place of window.location?

1 answer

1


You are using window.location that is, it will replace the current window, in case the map. To get the expected result, use window.location.href.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.