views:

148

answers:

2

is there a way where i can enter a city name and get the latitude and longitude for that location as i am trying to take a list of cities and dynamically populate a google maps webpage.

I have the idea of the code below but i dont have the Latitude or Longitude points.

        foreach (City city in cities)
        {
            markerString.AppendLine("       var point" + i + " = new GLatLng(" + city .Location.Latitude + "," + city .Location.Longitude + ");");
            markerString.AppendLine("       var marker" + i + " = new GMarker(point" + i + ");");
            markerString.AppendLine("       marker" + i + ".value = " + i + ";");
        }
+3  A: 

Yes. This is known as geocoding.

Google's javascript geocoding API: http://code.google.com/apis/maps/documentation/services.html#Geocoding

HTTP API: http://code.google.com/apis/maps/documentation/geocoding/index.html

A C# library for geocoding: http://code.google.com/p/geocoding-net/ (uses either Google, Yahoo or Microsoft).

codeape