How To Pass Value from database to google map( javascript function)

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GoogleMap.aspx.cs" Inherits="GoogleMap" %>

<!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 runat="Server">
 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
 <title>Google Maps JavaScript API Example</title>

 <script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAjQ5pL86XOoQ41VopETg1BxRfqogRWDFFWKC2bFG72235ZrnYERRoUjFELdorAiLMorc8KixeuNcskQ"
     type="text/javascript"></script>

 <script type="text/javascript">

 //<![CDATA[

 function load() {
   if (GBrowserIsCompatible()) {
   var lat = document.getElementById("lat").value;
   var lon = document.getElementById("lon").value;
   var map = new GMap2(document.getElementById("map"));
   map.setCenter(new GLatLng(lat,lon), 13);
   }
 }

 //]]>
 </script>

</head>
<body onload="load()" onunload="GUnload()">
 <form id="form1" runat="server">
 <div>
     <div id="map" style="width: 500px; height: 300px">
     </div>
 </div>
 </form>
</body>
</html>


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml.Linq;

public partial class GoogleMap : System.Web.UI.Page
{
 protected void Page_Load(object sender, EventArgs e)
 {   string lat = "37.4419";
     string lon = "-122.1419";

     Page.ClientScript.RegisterHiddenField("lat", lat);
     Page.ClientScript.RegisterHiddenField("lon", lon);

 }
}
Reactions

Post a Comment

0 Comments

Close Menu