how to point locations in gogle map

Posted by Sushant under JavaScript on 7/19/2013 | Points: 10 | Views : 1179 | Status : [Member] | Replies : 0
Hi all
I want to show map on my webpage,on That google map it should be markers on location which are in database..(ie. it should point location on map)
--------------------------------My java script-------------------------------------------------------------------
<script type="" src="js/vendor/modernizr-2.6.2-respond-1.1.0.min.js"></script>

<script src="//maps.google.com/maps?file=api&amp;v=2&amp;sensor=false&amp;key=AIzaSyBJFlhLcJMRXg_Aos67SdnJLqe-0MXPGm8"
type="text/javascript"></script>
<script type="text/javascript">
var map;

function initialize() {
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map_canvas"));
map.setCenter(new GLatLng(28.63531,77.22496), 14);
map.setUIToDefault();
}
}
function marker(arr)
{
var bounds = map.getBounds();

for (var i = 0; i <9; i++) {
var point = new GLatLng(arr[i][2],arr[i][3]);
map.addOverlay(new GMarker(point));

}
}
</script>

---------------In this java script I am passing arry which contains location details with longitude and latitude-----------------------

--------------calling of function on client side------------------------------
<body onload="initialize(); marker(location)" onunload="GUnload()">

----------------------server side code-----------------------------------
string [ , ] location=new string[100,4];
SqlCommand cmd;
SqlConnection cn;
SqlDataReader dr;
protected void Page_Load(object sender, EventArgs e)
{
cn = new SqlConnection(ConfigurationManager.ConnectionStrings["AdminConn"].ConnectionString);
GetLocationDetail();
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "marker(arr);", true);
}
private void GetLocationDetail()
{
try
{
cn.Open();
int i = 0;
string sid = "";
string sloc = "";
string lat = "";
string log = "";
cmd = new SqlCommand();
cmd.Connection = cn;
cmd.CommandText = "select LocID,LocationName,Latitude,Longitude from LocationMaster where Latitude!='NA' and Longitude!='NA'";
cmd.CommandType = CommandType.Text;
SqlDataAdapter da = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
da.Fill(ds);
for(i=0;i<ds.Tables[0].Rows.Count;i++)
{
sid = ds.Tables[0].Rows[i]["LocID"].ToString();
sloc = ds.Tables[0].Rows[i]["LocationName"].ToString();
lat = ds.Tables[0].Rows[i]["Latitude"].ToString();
log = ds.Tables[0].Rows[i]["Longitude"].ToString();
location[i,0] = sid;
location[i,1] = sloc;
location[i,2] = lat;
location[i,3] = log;
}
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
finally
{
cn.Close();

}

}


------------------------------My problem----------------------------------------------------
1.how can i call marker() function from server side so that i can pass location array
2.How can i debug java script (provided i am using visual studio 2005 and frame work 2.0)

Sushat


Responses

(No response found.)

Login to post response