Can anyone help me figure out what is wrong with the following code?
I have been banging my head all night since I am new to javascript.  I
am specifically having problems with the myclick function.  i want to
have a link <a href="javascript:myclick(0)">map it</a>, but I do not
seem to be able to get it to recognize.  any suggestions?  All help
appreciated.

var map;
var icon0;
var newpoints = [];

function myclick(i) {
GEvent.trigger(newpoints[i], "click");
 }
function addLoadEvent(func) {
        var oldonload = window.onload;
        if (typeof window.onload != 'function'){
                window.onload = func
        } else {
                window.onload = function() {
                        oldonload();
                        func();
                }
        }
}

addLoadEvent(loadMap);
addLoadEvent(addPoints);

function loadMap() {
        map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng( 41.86956082699455, -87.099609375), 5);
        map.setMapType(G_NORMAL_MAP);

        icon0 = new GIcon();
        icon0.image = "http://www.google.com/mapfiles/marker.png";;
        icon0.shadow = "http://www.google.com/mapfiles/shadow50.png";;
        icon0.iconSize = new GSize(20, 34);
        icon0.shadowSize = new GSize(37, 34);
        icon0.iconAnchor = new GPoint(9, 34);
        icon0.infoWindowAnchor = new GPoint(9, 2);
        icon0.infoShadowAnchor = new GPoint(18, 25);
}

function addPoints() {

        newpoints[0] = new Array(41.8756794 , -87.6400772, icon0, 's', 's');

        for(var i = 0; i < newpoints.length; i++) {
                var point = new GPoint(newpoints[i][1],newpoints[i][0]);
                var popuphtml = newpoints[i][4] ;
                var marker = createMarker(point,newpoints[i][2],popuphtml);
                map.addOverlay(marker);
        }
}

function createMarker(point, icon, popuphtml) {
        var popuphtml = "<div id=\"popup\">" + popuphtml + "<\/div>";
        var marker = new GMarker(point, icon);
        GEvent.addListener(marker, "click", function() {
                marker.openInfoWindowHtml(popuphtml);
        });
        return marker;
}

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Maps API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to