am using like this in my project once you go through this you may get something from this
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WatchDoctorLocation.aspx.cs"
Inherits="Inforaise.eMediTime.Web.ModalWindows.WatchDoctorLocation" %>
<!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></title>
<%----%>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script type="text/javascript">
$(document).ready(function () {
var geocoder;
jQuery.ajax({
type: "GET",
dataType: "json",
url: "http://maps.googleapis.com/maps/api/geocode/json",
data: { 'address': 'HYDERABAD', 'sensor': false },
success: function (data) {
if (data.results.length) {
initialize('<%=docLatitude %>', '<%=docLongitude %>');
} else {
alert("Invalid Address");
}
}
});
});
function initialize(Latitude, Longitude) {
var myLatlng = new google.maps.LatLng(Latitude, Longitude);
geocoder = new google.maps.Geocoder();
var mapOptions = {
zoom: 19,
center: myLatlng
}
var map = new google.maps.Map(document.getElementById('googleMap'), mapOptions);
var marker = new google.maps.Marker({
position: myLatlng,
map: map,
animation: google.maps.Animation.DROP
});
google.maps.event.addListener(marker, 'click', function () {
geocoder.geocode({ 'latLng': myLatlng }, function (results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[1]) {
map.setZoom(19);
marker = new google.maps.Marker({
position: myLatlng,
map: map
});
infowindow.setContent('' + '<%=DocLocation %>' + '' + ',' + '<br/>' + results[1].formatted_address);
infowindow.open(map, marker);
} else {
alert('No results found');
}
} else {
alert('Geocoder failed due to: ' + status);
}
});
});
var contentString;
var infowindow = new google.maps.InfoWindow({
content: contentString
});
var mapProp = {
center: new google.maps.LatLng(Latitude, Longitude),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
google.maps.event.addDomListener(window, 'load', initialize);
}
</script>
<style type="text/css">
#divGoogleMaps
{
height: 350px !important;
padding: 0px 0px !important;
}
#googleMap
{
position: fixed !important;
background-color: none !important;
}
.gm-style-iw
{
width: 120px !important;
height: auto !important;
}
</style>
</head>
<body>
<div id="googleMap" style="width: 100%; height: 100%">
</div>
</body>
</html>
in server side just am assigning the longitude and latitude values
public partial class WatchDoctorLocation : System.Web.UI.Page
{
public string docLongitude;
public string docLatitude;
public string DocLocation;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string DoctorLocation = Request.QueryString["DocLocation"];
string[] altitudes = DoctorLocation.Split(':');
docLongitude = altitudes[0];
docLatitude = altitudes[1];
DocLocation = altitudes[2];
}
}
}