This project is read-only.

Get Longitude & Latitude

Jan 18, 2008 at 2:41 AM
Hi Velio,

How to get longitude and latitude of a place if I provide the complete address like (Place Name, State, Country) or Postal code of Country?

Jan 18, 2008 at 11:53 AM
Hi Dev,

I suggest you check out Capture Position Sample.
Bare in your mind the ability to pass a custom java script function there, as well.

Jan 18, 2008 at 10:15 PM
Hi Velio,

Thanks for the quick reply and solution. But I am looking this kind of functionality by your control.


velio wrote:
Hi Dev,

I suggest you check out Capture Position Sample.
Bare in your mind the ability to pass a custom java script function there, as well.


Jan 21, 2008 at 4:48 PM
I see, then please, check out Geocoding Sample.

Mar 9, 2008 at 9:44 PM
Edited Mar 9, 2008 at 9:50 PM

I am using your GoogleMap control (latest release) you have published at CodePlex. This looks very nice.

I am trying to geocode an address. I have followed it the way you have showed it in the tutorial, but that did not do the trick.

I was able to show the google map and all controls (button and textbox) on the page. However, when I enter an address and expect it to show me a marker, it gives me a blank map (all greyed out).
Also, I want the latlon for the addres. How can I get it. The lat/long a property of GoogleMap control returned zero. But I guess, I am doing it right so that might be beyond the point.


Mar 10, 2008 at 9:20 AM
Hi Amit,

First of all you have to realize that geolocations (address) are solved on the client side, because of then Google Maps API is invoked.
That means if you enter address in a text box and post back to server, you have not solved and persisted Latitude and Longitude, but just set the address to google map.
Then after response is send back to client map is loaded and geolocation is solved.

If you want to add a marker to map center after an address is loaded then the proper way is to use GeolocationLoaded event.
That server side event is fired when and only if address is changed and geolocation is solved by Google Maps API, then lat and lng are persisted/cached in Latitude and Longitude properties and you can use them.
Have in mind GeolocationLoaded event fires automatically a post back to server once the addres is solved.

Here is sample of how that should look like:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <asp:Label ID="Label1" runat="server" Text="Enter Address:"></asp:Label>
            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
            <artem:GoogleMap ID="GoogleMap1" runat="server" Width="800px" Height="600px" Key="ABQIAAAA6mHGOYtX2B_jXOq7x-k13hQ-52lfuyIOhkXmFHmfJvd3RGectRSxSrVb-5-dG1rnqZ9QI0uVyJXU7g"
                Latitude="42" Longitude="24" Zoom="5" Style="z-index: 26; left: 12px; position: absolute; top: 104px"
                BorderStyle="Solid" ShowClientClickPosition="True" ShowTraffic="True" ZoomPanType="Large" OnGeoLocationLoaded="HandleGeolocationLoaded">
and code-behind (in C#)
public partial class _Default : System.Web.UI.Page {
    protected void HandleGeolocationLoaded(object sender, EventArgs e) {
        GoogleMap1.Markers.Add(new Artem.Web.UI.Controls.GoogleMarker(GoogleMap1.Latitude, GoogleMap1.Longitude));
    protected void Page_Load(object sender, EventArgs e) {
        if (IsPostBack)
            GoogleMap1.Address = TextBox1.Text;

Hope this helps.
I'm working on next release where I have added Sample Website to the GoogleMap control solution and it will be available for download in release files.
In the sample website I'll include samples for using any of the features of GoogleMap control.
The website will be available online at (a beta is now available there) and for download with next release.

Mar 10, 2008 at 4:25 PM
Hi Velio,

Thanks for the reply. Please check my email also.

In the code shown above for form, do you still need OnClick="Button1_Click"
If the geocoding is being solved at the server using your wrapper, this may not be needed. Or is it? If yes, what code goes behid the button click event?