I have problem in implementing google maps api in asp.net. Here is my aspx code:\[code\]<%@ Page Title="" Language="C#" AutoEventWireup="true" CodeFile="visual_loc.aspx.cs" Inherits="visual_loc" %><%--A sample project by Ghaffar khan--%><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Your Data on Google Map </title> <%--Google API reference--%> <script src="http://maps.google.com/maps?file=api&v=2&sensor=false &key=asdfg" type="text/javascript"> </script></head><body onload="initialize()" onunload="GUnload()"> <form id="form1" runat="server"> <aspanel ID="Panel1" runat="server"> <%--Place holder to fill with javascript by server side code--%> <asp:Literal ID="js" runat="server"></asp:Literal> <%--Place for google to show your MAP--%> <div ID="map_canvas" style="width: 100%; height: 728px; margin-bottom: 2px;"> </div> <br /> </aspanel> <br /> </form> </body></html>\[/code\]And my code behind:
\[code\]getLocation()\[/code\] is the method which gets the longitude and latitude from my database. \[code\]createDataTable()\[/code\] is method which create \[code\]DataTable\[/code\] from those locations.\[code\]protected void Page_Load(object sender, EventArgs e) { string user_id; user_id = Request.Cookies["cookie"]["Login"]; getLocation(user_id); BuildScript( createDataTable()); } private void BuildScript(DataTable tbl) { String Locations = ""; foreach (DataRow r in tbl.Rows) { // bypass empty rows if (r["Latitude"].ToString().Trim().Length == 0) continue; string Latitude = r["Latitude"].ToString(); string Longitude = r["Longitude"].ToString(); // create a line of JavaScript for marker on map for this record Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + Latitude + "," + Longitude + ")));"; } // construct the final script js.Text = @"<script type='text/javascript'> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById('map_canvas')); map.setCenter(new GLatLng(52.259, 21.012), 2); " + Locations + @" map.setUIToDefault(); } } </script> "; }\[/code\]whole operation result in displaying empty site with no content. What am i doing wrong?
\[code\]getLocation()\[/code\] is the method which gets the longitude and latitude from my database. \[code\]createDataTable()\[/code\] is method which create \[code\]DataTable\[/code\] from those locations.\[code\]protected void Page_Load(object sender, EventArgs e) { string user_id; user_id = Request.Cookies["cookie"]["Login"]; getLocation(user_id); BuildScript( createDataTable()); } private void BuildScript(DataTable tbl) { String Locations = ""; foreach (DataRow r in tbl.Rows) { // bypass empty rows if (r["Latitude"].ToString().Trim().Length == 0) continue; string Latitude = r["Latitude"].ToString(); string Longitude = r["Longitude"].ToString(); // create a line of JavaScript for marker on map for this record Locations += Environment.NewLine + " map.addOverlay(new GMarker(new GLatLng(" + Latitude + "," + Longitude + ")));"; } // construct the final script js.Text = @"<script type='text/javascript'> function initialize() { if (GBrowserIsCompatible()) { var map = new GMap2(document.getElementById('map_canvas')); map.setCenter(new GLatLng(52.259, 21.012), 2); " + Locations + @" map.setUIToDefault(); } } </script> "; }\[/code\]whole operation result in displaying empty site with no content. What am i doing wrong?