i m designing a website in which i am using Google map api for showing map and multiple markers of different locations on map . The latitude and longitude are save in my database and in a for loop i m calling a javascript function in which markers are created.The main problem is that the function is calling on each iteration but the marker on the map is shows of only first record .I am using function
Page.ClientScript.RegisterStartupScript(this.GetType(), i.ToString(), "getpoint(" + ds.Tables[0].Rows[i]["Latitude"] + "," + ds.Tables[0].Rows[i]["Longitude"] + "," + str1 + "," + str2 + "," + str3 + ");", true);
to call javascript function getpoint(),the code of function is given below:
function createMarker(point, html) {
map = new GMap2(document.getElementById("map_canvas"));
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function () {
marker.openInfoWindowHtml(html);
});
return marker;
}
function getpoint(lat,lon, image, name, adress)
{
alert("hello");
if (GBrowserIsCompatible())
{
point = new GLatLng(lat, lon);
marker = createMarker(point, '<table><tr><td> <a href="/KB/answers/umaid.aspx"><img src=' + image + ' width=50 height=50 vspace=0 hspace=10 align=left/><\/a></td><td valign=top>' + name + '<br/>' + adress + '</td></tr></table>')
map.addOverlay(marker);
map.setCenter(new GLatLng(26.2816, 73.0232), 13);
map.setUIToDefault();
}
}
Please help me as soon as possible.
Thanks.