Here are 4 simple steps to include a Google map in your ASP.Net web page :
- Register on http://www.google.com/apis/maps/ for an API Key.
- Include the GeoCode class in your project (http://blog.donnfelker.com/2007/03/13/CGoogleGeocodeLatitudeAndLongitudeClass.aspx)
- First, you need to get Latitude and Longitude of the address in the codebehind
Dim Coord As CoordinateCoord = Geocode.GetCoordinates(“1600 Amphitheatre Parkway,Mountain View, CA 94043″)
_LONGITUDE = Coord.Longitude ‘_LONGITUDE is a class level public variable
_LATITUDE = Coord.Latitude ‘_LONGITUDE is a class level public variable
- In your ASPX page,
<table>
<tr align="center">
<td colspan="2">
<div id="map" style="width: 450px; height: 300px">
</div>
<script src="http://maps.google.com/maps?file=api&v=2&key=XXXXXXXX" type="text/javascript">
</script>
<script type="text/javascript">
//<![CDATA[
function load() {
if (GBrowserIsCompatible()){
var map = new GMap2(document.getElementById("map"));
map.setCenter(new GLatLng(<%=LATITUDE %>, <%=LONGITUDE %>), 13); var point = new GLatLng(<%=LATITUDE %>, <%=LONGITUDE %>);
var marker = new GMarker(point);map.addOverlay(marker);
marker.openInfoWindowHtml('<b>html content</b>');}
}
//]]>
</script>
</td>
</tr>
</table>
Just replace the XXXXXXXXXXXXXX with your API key and you are good to go. Happy Mapping !
Filed under: .Net 2.0, .net 1.1, ASP.NET 1.1, ASP.net 2.0 | Tagged: linkedin
Great writeup. Keep the good work going. I visit your blog regularly.
Mine is http://www.taxe.wordpress.com. Do visit and share your views…
[url=http://hotfrog.fr/Entreprises/VIAGRA-ACHETER-VIAGRA-VIAGRA-ONLINE]viagra[/url] panel