Jump to content

Click a html link display box on google map


smith.james0

Recommended Posts

I am trying to make the script work so that when you click a html link, it displays the info box on google map.

 

My links is <a href="javascript:void(0);" onclick="infoOpen('1');">open it</a> (This is number one, of 250+)

 

my code is


    var map = new google.maps.Map(document.getElementById('map'), {
      zoom: 6,
      center: new google.maps.LatLng(53.839564,-4.306641),
      mapTypeId: google.maps.MapTypeId.ROADMAP
    });

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

    var marker, i;

    for (i = 0; i < locations.length; i++) {  
      marker = new google.maps.Marker({
        position: new google.maps.LatLng(locations[i][1], locations[i][2]),
        map: map,
		icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+locations[i][3]+'|FF0000|000000'
      });

function infoOpen(i)
{
    google.maps.event.trigger(marker[i],'click');
}
			
      google.maps.event.addListener(marker, 'click', (function(marker, i) {
        return function() {
          infowindow.setContent(locations[i][0]);
          infowindow.open(map, marker);
        }
      })(marker, i));
    }
  </script>

if I mess around with infoOpen i can get it to open the 250th box but i can not click anything else.

 

Can anyone tell me what I am doing wrong?

 

James

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.