RSS Feed

Integrating Google Maps into an ASP.NET Page : Google Maps API

September 23, 2011 by Sourabh Sharma

Google Map is a web mapping service application and technology provided by Google, free (for non-commercial use), that powers many map-based services, including the Google Maps website, Google Ride Finder, Google Transit,and maps embedded on third-party websites via the Google Maps API. In this article you will see how to integrate the Google Map into your ASP.NET Application. Also you will get the information to show a particular point on Google Map. In this project there are four parameters Street, City, State and Country. After you pass these four Parameters you will get the exact place on Google Map. To show Google Map you need to add a reference, dll file named “GMaps.DLL” in your project. Also you need to add a key for Google map in web.config file.


 


Free Download: 
Google Map Application : Demo Project

 Get DLL Here : GMaps.DLL

 

 

Source Code of Web Page

<form id=“form1″ runat=”server”><div>

 Streat
 <asp:TextBox ID="TextBox1" runat="server" Font-Bold="True" Height="20px"
     Width="175px"></asp:TextBox>
 City
 <asp:TextBox ID="txtCity" runat="server" Font-Bold="True" Width="175px"></asp:TextBox>
 State
 <asp:TextBox ID="txtState" runat="server" Font-Bold="True" Width="175px"></asp:TextBox>
 Country
 <asp:TextBox ID="txtCountry" runat="server" Font-Bold="True" Width="175px"></asp:TextBox>
 <asp:Button ID="btnShowMap" runat="server" Font-Size="Small" Height="30px"
   onclick="btnShowMap_Click" Text="ShowMap" Width="99px" />
  <cc1:GMap ID="GMap1" runat="server" Width="800px" />
</div> </form>


Aspx.cs Page Code: 

protected void btnShowMap_Click(object sender, EventArgs e)

    {
        string fulladdress = string.Format("{0}.{1}.{2}", TextBox1.Text, txtCity.Text, txtCountry.Text);
        string skey = ConfigurationManager.AppSettings["googlemaps.subgurim.net"];
        GeoCode geocode;
        geocode = GMap1.getGeoCodeRequest(fulladdress);
        var glatlng = new Subgurim.Controles.GLatLng(geocode.Placemark.coordinates.lat, geocode.Placemark.coordinates.lng);
        GMap1.setCenter(glatlng, 16, Subgurim.Controles.GMapType.GTypes.Normal);
        var oMarker = new Subgurim.Controles.GMarker(glatlng);
        GMap1.addGMarker(oMarker);
    }


web.config Page Code

<configuration>

 <appSettings>
	<add key="googlemaps.Subgurim.net" value="YourGoogleMapsAPIKeyHere="/>
</appSettings>
</configuration>




4 Comments »

  1. Considerably, this post is really the sweetest on this notable topic. I harmonise with your conclusions and will thirstily look forward to your incoming updates. Saying thanks will not just be sufficient, for the phenomenal clarity in your writing. I will directly grab your rss feed to stay informed of any updates. Admirable work and much success in your business dealings!.

  2. JBurch175 says:

    How to add street view to the marker infowindow? Any examples?

  3. High Definition Wallpaper says:

    Your blog is a great one. Wonderful, that’s exactly what I was searching for! You just saved me a lot of work. Thank you for this blog. High Definition Wallpaper

  4. sam says:

    I have a problem;
    using Subgurim.Controles could not be found and even GeoCode geocode. Any help please?

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>