[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to know the latitude and longitude of a given address

Posted on 2011-10-08
8
Medium Priority
?
576 Views
Last Modified: 2012-05-12
Hi ,
if I supply the details like
Address:
City:
State:
Country:
Zip Code:
in an asp.net page

How can I get the values of the latitude and longitude of the address using C#
0
Comment
Question by:mauneeld
  • 4
  • 3
8 Comments
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 36938243
you can use google maps api.
Refer following link
http://code.google.com/apis/maps/documentation/javascript/v2/overlays.html
0
 

Author Comment

by:mauneeld
ID: 36938359
Hi RamKisan,

I am unable to find the code snippet which takes in address as the input from the user and then give the coordinates i.e..., latitude and longitude of that address.

0
 
LVL 12

Expert Comment

by:Ramkisan Jagtap
ID: 36938403
please che following example link. View source for code.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 12

Accepted Solution

by:
Ramkisan Jagtap earned 2000 total points
ID: 36938441
0
 
LVL 1

Expert Comment

by:ggeek
ID: 36938863
Google Maps geocoding service can be used.
Since the question was about C# you may use this small C# wrapper of the Google Maps geocoding service:
http://code.google.com/p/geocodingapi/






private static readonly List<string> Addresses = new List<string> 
{ 
    "1600 Amphitheatre Parkway, Mountain View, CA 94043",       // Google 
    "1 Microsoft Way, Redmond, WA 98052",                       // Microsoft 
    "1601 S. California Ave., Palo Alto, CA 95304",             // Facebook 
    "701 First Ave, Sunnyvale, CA 94089"                        // Yahoo 
}; 
 
// The API is rate limited.  1 request every 0.5 seconds seems to keep Google happy. 
private static readonly int DelayInMs = 500; 
 
static void Main(string[] args) 
{ 
    foreach (string address in Addresses) 
    { 
        Geocoding.Geocode(address) 
            .ForEach(coordinate => DisplayCoordinate(coordinate, address)); 
 
        Thread.Sleep(DelayInMs); 
    } 
} 
 
 
private static void DisplayCoordinate(GeographicCoordinate coordinate, string address) 
{ 
    Console.WriteLine("Geographic coordinate for '{0}':", address); 
    Console.WriteLine( 
        "\t* Latitude: {0}, Longitude: {1}", 
        coordinate.Latitude, 
        coordinate.Longitude 
        ); 
}

Open in new window

0
 

Author Comment

by:mauneeld
ID: 36939891
Hi ggeek,
For the code which you supplied needs to have a key...but I dont have a key since I do not have an URL...
Is there a way to get a key without providing the URL
0
 

Author Comment

by:mauneeld
ID: 36939922
Hi Ramkisan,

I am getting the address correctly, but how do I find the latitude and longitude of the specified address?
With the code over the link
http://www.stackoverflow.com/questions/3684765/google-maps-using-geocoder-to-get-long-lat-with-javascript

I am unable to still find the latitude and longitude of a given location.
0
 

Author Closing Comment

by:mauneeld
ID: 36940370
Solution was easy to follow
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question