Here’s my issue. I have a function created that listens for a click on a link in the sidebar, and when that click happens, it does some stuff with the Google map I have. Problem is the function is firing when I click on one of the links and I can’t for the life of me figure out why.
Here’s the site where I found the code:
[url]http://econym.googlepages.com/basic2.htm
And here’s the site where I’m using the code where you can see the problem:
[url]http://bellevue.com/restaurant.php
Here’s the javascript I’m using:
[CODE]window.onload = load;
var map;
var gmarkers = [];
// This function picks up the click and opens the corresponding info window
function myclick(i) {
GEvent.trigger(gmarkers[i], “click”);
alert(booyah);
}
//<![CDATA[
function load() {
if (GBrowserIsCompatible()) {
// this variable will collect the html which will eventually be placed in the side_bar
var side_bar_html = “”;
// arrays to hold copies of the markers and html used by the side_bar
// because the function closure trick doesnt work there
var gmarkers = [];
var i = 0;
// A function to create the marker and set up the event window
function createMarker(point,name,html) {
var marker = new GMarker(point);
GEvent.addListener(marker, “click”, function() {
marker.openInfoWindowHtml(html);
});
// save the info we need to use later for the side_bar
gmarkers[i] = marker;
// add a line to the side_bar html
side_bar_html += ‘<a href=”javascript:myclick(‘ + i + ‘)”>’ + name + ‘</a><br>’;
i++;
return marker;
}
// create the map
var map = new GMap2(document.getElementById(“map”));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng( 43.907787,-79.359741), 8);
// add the points
var point = new GLatLng(43.65654,-79.90138);
var marker = createMarker(point,”This place”,”Some stuff to display in the<br>First Info Window”)
map.addOverlay(marker);
var point = new GLatLng(43.91892,-78.89231);
var marker = createMarker(point,”That place”,”Some stuff to display in the<br>Second Info Window”)
map.addOverlay(marker);
var point = new GLatLng(43.82589,-78.89231);
var marker = createMarker(point,”The other place”,”Some stuff to display in the<br>Third Info Window”)
map.addOverlay(marker);
// put the assembled side_bar_html contents into the side_bar div
document.getElementById(“side_bar”).innerHTML = side_bar_html;
}
//]]>
}
Much thanks for any help!