tags:

views:

317

answers:

1

Prior to showing an InfoWindow on the map I am calling setContent. The content being set contains a hyperlink. Everything works and the InfoWindows is displayed, however when you click on the "Driving Directions" hyperlink nothing happens.

var infoWindowHtml = '<a href="http://www.google.com/maps?daddr=Aliso+Viejo,+CA" target="_blank">Driving Directions</a>'
infoWindow.setContent(infoWindowHtml);
infoWindow.open(map, this);
A: 

You might be having some problem elsewhere, or there's an aggressive popup blocker that is blocking the new window, because the following short example works perfectly in my browsers (Chrome and Firefox):

<!DOCTYPE html>
<html> 
<head> 
  <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> 
  <title>Google Maps API InfoWindow Demo</title> 
  <script src="http://maps.google.com/maps/api/js?sensor=false" 
          type="text/javascript"></script>
</head> 
<body>
  <div id="map" style="width: 400px; height: 500px;"></div>

  <script type="text/javascript">
    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 4,
      center: new google.maps.LatLng(-25.36388, 131.04492),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

    var infowindow = new google.maps.InfoWindow();

    infowindow.setContent('<a href="http://www.google.com/maps?'+
      'daddr=Aliso+Viejo,+CA" target="_blank">Driving Directions</a>');

    var marker = new google.maps.Marker({
      position: map.getCenter(),
      map: map
    });

    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(map,marker);
    });

  </script>
</body>
</html>
Daniel Vassallo
Daniel thanks for the quality example. I tried it out in all of my browsers and it worked perfectly, so I don't think it is a pop up blocker. It must be something I am doing else were with the map. I am listening to the "closeclick" event for the InfoWindow. I thought that may have been hijacking the clicks to the hyperlink, but I commented that out and same problem. Here is the page that is having the problem: http://coav.beta2.nssg.com/map/Any additional insight is deeply appreciated.
jacksonakj