How To Add Google Map to Your Web Application

Here is an example of how you can add a map to any contact us page or blog quickly and easily. •First you need a google api key ,which is free. You can find it,along with other documentation at Follow the instructions to "Sign up for a google API key". You'll need a gmail account, and to enter your domain name. This key can then only be used on pages served from that domain name. Along with your key, Google will give you a bit of starter code. Now create a new web application in and copy the highlited code in head section of your .aspx page.(replace [YOURKEY] with actual key)
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GoogleMap.aspx.cs"
    Inherits="GoogleMap" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="">
    <script src="
[YOURKEY]" type="text/javascript"></script>
    <script type="text/javascript">
        function showMap()
                if (GBrowserIsCompatible()) {
                var map = new GMap2(document.getElementById("map"));
                map.addControl(new GSmallMapControl());
                map.setCenter(new GLatLng(31.95216223802497, -7.71875), 1);

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

Post a Comment


Close Menu