Hi.
Today, I want implement Google Map on my site(on ASP.NET 2). I need create boundary to each user of my site.
Ok. Lets do this.
First create account on http://www.google.com/accounts/)
Then I need to get unique Key for test version of my site on localhost.
Full path of my site is http://localhost/MySiteTitle/gmap.aspx (this is no master page), but it works only when I get key for one

After that I implement scripts in my aspx code:
gmap.aspx
<script src="http://maps.google.com/maps?file=api&v=2&key=my_recived_key"
type="text/javascript"></script>
Then I make script to visualize Map, for example:
<script type="text/javascript">
//<![CDATA[
var map;
var pntx=0;
var pnty=0;
var map_ctrl;
var map_type_ctrl;
var map_scale_ctrl;
function load(){
if (GBrowserIsCompatible()) {
map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(pntx, pnty), 1);
map_ctrl=new GLargeMapControl();
map_type_ctrl=new GMapTypeControl();
map_scale_ctrl=new GScaleControl();
map.addControl(map_ctrl);
/* Add Map Type Control*/
map.addControl(map_type_ctrl);
/* Add Map Scale Control*/
map.addControl(map_scale_ctrl);
}
}
//]]>
</script>
Then I need to wrote some code like this:
<body onload="load()" onunload="GUnload()">
<div id="map" style="width: 500px; height: 300px"></div>
</body>
But my map is visualize not at master page, so I wrote next one:
site.master
...
<body id="MasterBodyId" runat="server">
...
in site.master.cs I create a new property
...
public HtmlGenericControl Body
{
get { return this.MasterBodyId; }
}
....
in gmap.aspx I create new div element
...
<%@ MasterType VirtualPath="~/site.master" %>
...
<div id="map" style="width: 450px; height: 300px" >
</div>
...
in gmap.aspx.cs I wrote this code
...
protected void Page_Load(object sender, EventArgs e)
{
this.Master.Body.Attributes["onload"] = "load()";
this.Master.Body.Attributes["onunload"] = "GUnload()";
...
}
...
Good I have a Google Map at my page. Remain part of the day I`ll read Google Maps API
on http://www.google.com/apis/maps/documentation/index.html.
<!--googleAd-->
Thanks for mentioning
Zsss
thanx but actually i need a
please send me the tutorial
This tutorial is a really
what will be the code for changing connectionstring for the foll
Hi
Thanks
Thanks for the tip. I
Something big, I'll read it
Comments