The Javascript:
<head runat="server">
<title>Google map Page</title>
<script src="http://maps.google.com/maps?file=api&v=2&sensor=false&key=ABQIAAAA6TS6WR4jbbUjikFVO_rihBSsoQeukxbo2NPugNeooGWFf_yQhRSk4JGGBtb5COzcswcwgPpu5XJo3Q"
type="text/javascript"></script>
<script type="text/javascript">
var map=null;
var Head = 'style="color:White;background-color:#339900;font-family:Verdana;font-size:11px;font-weight:bold;"';
var Data = 'style="background-color:#ffff99;font-family:Verdana;font-size:11px;overflow:auto; "';
var gmarkers = [];
var ghtml = [];
var m = 0;
function load()
{
if (GBrowserIsCompatible())
{
var LatitudePoint='<%= LatitudePoint %>';
var LongitudePoint='<%= LongitudePoint %>';
var RestaurantName='<%= RestaurantName%>';
var RestaurantAddress='<%=RestaurantAddress%>';
var map = new GMap(document.getElementById("map"));
var point = new GPoint(LatitudePoint,LongitudePoint);
map.addControl(new GLargeMapControl());
map.setCenter(new GLatLng(LatitudePoint,LongitudePoint), 5 );
function createMarker(point,Html)
{
var marker = new GMarker(point);
GEvent.addListener(marker, "click", function()
{
//marker.openInfoWindowHtml('<div class="infodescription">'+Html+'</div>');
marker.openInfoWindowHtml(Html);
});
return marker;
}
var request = GXmlHttp.create();
request.open("GET", "parks.xml", true);
request.onreadystatechange = function()
{
if (request.readyState == 4)
{
var xmlDoc = request.responseXML;
var points = xmlDoc.documentElement.getElementsByTagName("park");
for (var i = 0; i < points.length; i++)
{
var point = new GPoint(LongitudePoint,
LatitudePoint);
var cHtml = '<table cellspacing=0 cellpading=0 border=1>' +
'<tr>' +
'<td align="center">' + RestaurantName + '</td>' +
'</tr>'+
'<tr>' +
'<td>' + RestaurantAddress + '</td>' +
'</tr>' +
'</table>';
var marker = createMarker(point,cHtml);
map.addOverlay(marker);
marker.openInfoWindowHtml(cHtml);
}
}
}
request.send(null);
}
}
</script>
</head>
<body onload="load()">
<form id="form1" runat="server">
<div>
<div id="map" style="width: 700px; height: 590px;">
</div>
</div>
</form>
</body>
The XML File: (parks.xml)
<parks>
<park FullName="Test" address="8,GN Road" lng="80.2385401725769" lat="13.048898223457536"/>
<park FullName="Birds Fort Trail Park" address="575 North Usman Road" lng="80.2496401725769" lat="13.059898223457536"/>
</parks>
Asp.Net C# Coding:
public string LatitudePoint = "12.916051";
public string LongitudePoint = "80.024414";
public string RestaurantName = "Rangish";
public string RestaurantAddress = "";
public string strRestaurantID = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
LatitudePoint = "70.5896";
LongitudePoint = "80.2568";
RestaurantName = "Test Name";
RestaurantAddress = "Dharapuram";
}
}
No comments:
Post a Comment