简体   繁体   中英

creating google maps website - map city to latitude and longitude

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 + ";");
        }

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM