google map api 可以得到某个标注点的地理坐标(经度和纬度),
但如何根据地理坐标得到对应的国家城市名称呢?
谢谢啦!

解决方案 »

  1.   

    可以用GClientGeocoder对象来获取。      function initialize() {
            if (GBrowserIsCompatible()) {
            
              // Create and Center a Map
              var map = new GMap2(document.getElementById("map_canvas"));
              var geocoder = new GClientGeocoder();
              map.setCenter(new GLatLng(37.4419, -122.1419), 13);
              map.addControl(new GLargeMapControl());
              map.addControl(new GMapTypeControl());          GEvent.addListener(map,"click", function(overlay,latlng) {     
               geocoder.getLocations(latlng, showAddress);
              });          
              
            }
          }
          
          function showAddress(response) {
           if(response && response.Status.code == "200") {
           alert("地址:" + response.Place[0].address);
           alert("国家:" + response.Place[0].AddressDetails.Country.CountryName);
          
           }
          }