I am new to JavaScript and I am trying to add 31 markers that also
show a specific info window for each marker. I also am showing the
GTrafficOverlay. You can view my test URL here:
http://www.invisionequity.com/htmlpages/howitworks.html
My first marker is showing up, but not really sure how to show the
remaining 30?
I would be grateful for any help.
Code:
var trafficInfo;
var toggleState = 1;
function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(33.539983,-117.673788), 10);
map.setUIToDefault();
var trafficOptions = {incidents:true};
trafficInfo = new GTrafficOverlay(trafficOptions);
map.addOverlay(trafficInfo);
function newMarker(lat, lng, name) {
var marker = new GMarker(new GLatLng(lat, lng));
GEvent.addListener(marker, "click", function() {
marker.openInfoWindowHtml(name);
});
var markerOne = new GMarker(new GLatLng(lat, lng));
GEvent.addListener(markerOne, "click", function() {
markerOne.openInfoWindowHtml(name);
});
/*GEvent.addListener(marker, "mouseover", function() {
marker.setImage("images/yellow.png");
});
GEvent.addListener(marker, "mouseout", function() {
marker.setImage("images/marker.png");
});*/
return marker;
//return markerOne;
}
map.addOverlay(
newMarker(33.539983, -117.673788, "I-5/CA-73"));
/*newMarker(33.558071, -117.685676, "Greenfield Dr."));
newMarker(33.569085, -117.700267, "Moulton Pkwy."));
newMarker(33.573519, -117.706532, "La Paz Rd."));
newMarker(33.580599, -117.721124, "Aliso Creek Rd."))
newMarker(33.58732, -117.732968, "Greenwood Dr. / Pacific Park
Dr."));
newMarker(33.590966, -117.759833, "El Toro Rd."));
newMarker(33.592325, -117.759833, "Laguna Canyon (CA-133)"))
newMarker(33.622705, -117.827811, "Newport Coast Dr."))
newMarker(33.630996, -117.841887, "Bonita Canyon Dr."));
newMarker(33.637785, -117.856221, "Bison Ave.","11"];
newMarker(33.655505, -117.865148, "University Dr. S. / Jamboree
Rd."));
newMarker(33.661148, -117.872958, "Birch St."));
newMarker(33.673435, -117.886262, "I-55/CA-73"));
newMarker(33.681721, -117.893643, "Bear St."));
newMarker(33.687291, -117.898622, "I-405/CA-73"));
newMarker(33.651647, -117.753224, "I-405/CA-133"));
newMarker(33.667792, -117.753224, "I-5/CA-133"));
newMarker(33.696861, -117.735715, "Irvine Blvd. E."));
newMarker(33.586891, -117.611089, "Oso Pkwy."));
newMarker(33.629781, -117.598815, "Antonio Pkwy."));
newMarker(33.642715, -117.603965, "Santa Margarita Pkwy."));
newMarker(33.654933, -117.624993, "Los Alisos Blvd."));
newMarker(33.667864, -117.651086, "Portola Pkwy. S."));
newMarker(33.671578, -117.660441, "Lake Forest Dr."));
newMarker(33.680006, -117.673144, "Alton Pkwy."));
newMarker(33.695647, -117.692714, "Portola Pkwy. N."));
newMarker(33.782724, -117.747731, "Chapman / Santiago Canyon (CA-261/
CA-241)"));
newMarker(33.863441, -117.716489, "CA-241/CA-91"));
newMarker(33.726277, -117.778974, "Irvine Blvd. W."));
newMarker(33.740909, -117.7667, "Portola Pkwy. W."))*/
}
}
function toggleTraffic() {
if (toggleState == 1) {
map.removeOverlay(trafficInfo);
toggleState = 0;
} else {
map.addOverlay(trafficInfo);
toggleState = 1;
}
}
--
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.